-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
28 lines (24 loc) · 792 Bytes
/
Copy pathserver.js
File metadata and controls
28 lines (24 loc) · 792 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
process.on('uncaughtException', (error) => {
console.log(`uncaughtException`);
console.log(error.name, error.message, error.stack);
process.exit(1);
});
require('dotenv').config({ path: './config.env' });
require('./dataBase.js').dataBase(process.env.DATABASE_LOCAL);
const chalk = require('chalk');
const app = require('./app');
const port = process.env.PORT || 3000;
const server = app.listen(port, () => {
console.log(
chalk.inverse
.green`app running in '${process.env.NODE_ENV}' mode on port{yellow : ${port}}`
);
});
process.on('unhandledRejection', (error) => {
console.log(chalk`{inverse.red unhandledRejection}`);
console.log(error.name, error.message, error.stack);
server.close(() => {
console.log('shutting down');
process.exit(1);
});
});