-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
34 lines (29 loc) · 1.03 KB
/
index.js
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
const configureAndStartMongoose = require('./api/configuration/mongoose');
const seedRoles = require('./api/components/role/role.seeder');
const seedUsers = require('./api/components/user/user.seeder');
const createServer = require('./api/server');
require('dotenv').config();
async function init () {
await configureAndStartMongoose();
// run seeder functions
await seedRoles();
await seedUsers();
const server = createServer();
return server;
}
init().then(server => {
// Start the server
server.listen(process.env.PORT, async () => {
console.log(`Listening at http://localhost:${process.env.PORT} in ${process.env.NODE_ENV} mode`);
});
});
if (process.env.NODE_ENV === 'production') {
// Catch any uncaught exceptions in this application
process.on('uncaughtException', (err) => {
console.log(`There was an uncaught exception: ${err}`);
});
// Catch any unhandled rejections in this application
process.on('unhandledRejection', (err) => {
console.log(`There was an unhandled rejection: ${err}`);
});
}