-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
37 lines (32 loc) · 968 Bytes
/
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
35
36
37
import bodyParser from 'body-parser';
import cookieParser from 'cookie-parser';
import cors from 'cors';
import express from 'express';
import http from 'http';
import router from './src/routes/index.js';
import Database from './src/utils/database.js';
import Services from './src/utils/services.js';
import Queue from './src/utils/queue.js';
import Schedule from './src/utils/schedule.js';
const load = async () => {
const app = express();
app.use(cors());
app.use(cookieParser());
app.use(express.json());
app.use([bodyParser.json(), bodyParser.urlencoded({ extended: false })]);
app.use('/v1', router);
await Database.load();
await Services.load();
await Queue.load();
await Schedule.load();
const server = http.createServer(app);
server.listen(process.env.PORT || 8000);
};
load()
.then(() => {
console.log('Server started !');
})
.catch((error) => {
console.log('Server is crashed: ', error);
process.exit(1);
});