-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
37 lines (32 loc) · 967 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
require('dotenv').config();
const express = require('express');
const app = express();
const cors = require('cors');
const serviceLocator = require('./app/helpers/service_locator');
const { app_config } = require('./app/config');
const PORT = app_config.APP_PORT;
const Database = require('./app/config/database');
let domainService = serviceLocator.get('domainServiceV1');
let connectDB = async () => {
await Database._connect(app_config.MONGO_URI);
};
let startBot = async () => {
domainService.startScan();
serviceLocator.get('logger').info('PingBot started');
};
let startServer = async () => {
app.use(cors());
require('./app/base/middleware')(app);
require('./app/base/routes')(app);
require('./app/base/handler')(app);
app.listen(PORT, function () {
serviceLocator.get('logger').info(`App listening on port ${PORT}!`);
});
};
connectDB();
if (app_config.START_BOT) {
startBot();
}
if (app_config.START_SERVER) {
startServer();
}