-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·48 lines (43 loc) · 980 Bytes
/
index.js
File metadata and controls
executable file
·48 lines (43 loc) · 980 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const loader = require('./app/loaders');
// Load dependencies and connections
loader
.run()
.then(({ logger, fastify }) => {
const { PORT, env } = require('./config');
// Catching errors
process.on('uncaughtException', (err) => {
logger.fatal(err);
process.exit(1);
});
process.on('unhandledRejection', (err) => {
logger.fatal(err);
process.exit(1);
});
if (env !== 'production') {
fastify.ready((err) => {
if (err) {
logger.fatal(err);
throw err;
}
fastify.swagger();
});
}
// Start the server
fastify.listen(PORT, '0.0.0.0', function (err, address) {
if (err) {
logger.fatal(err);
process.exit(1);
}
logger.info({
type: 'APPLICATION_ONLINE',
message: {
port: PORT,
address,
},
});
});
})
.catch((err) => {
console.error(err);
process.exit(1);
});