-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
44 lines (32 loc) · 1.03 KB
/
app.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
35
36
37
38
39
40
41
42
43
44
require("dotenv").config();
const express = require('express');
const bodyParser = require('body-parser');
const configuration = require('./config');
const router = require('./route/routes');
const { agenda, jobsReady } = require('./services/agendaServices');
//const expressValidator = require('express-validator');
//express
const app = express();
//app.use(expressValidator());
const PORT = configuration.port;
agenda;
jobsReady;
//config
require("./configs")
//middleware definition
app.use(bodyParser.json({ limit: '50MB' }));
app.use(bodyParser.urlencoded({ limit: '50MB', extended: false }));
app.use('/',router);
//starting the server at port defined in config.js
const server=app.listen( PORT,()=> {
console.log(`server started at: http://localhost:${PORT}`);
});
async function graceful() {
console.log("\nClosing server...");
await server.close();
console.log("Shutting down gracefully...");
await agenda.stop();
process.exit(0);
}
process.on("SIGTERM", graceful);
process.on("SIGINT", graceful);