-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
34 lines (26 loc) · 845 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
const express = require('express');
const {createServer} = require('http');
const fs = require('fs');
const path = require('path');
//Config
const { PORT, NODE_ENV } = require('./src/config/env.js');
const port = PORT || 8080;
if (fs.existsSync(path.join(__dirname, '/iologs.txt'))) {
fs.rmSync(path.join(__dirname, '/iologs.txt'));
}
//Create Application
const app = express();
//Socket.io initialization
const httpServer = createServer(app);
const endpoints = require('./src/routes/index.routes');
endpoints(app, httpServer);
if (NODE_ENV == 'dev') {
httpServer.listen(process.argv[2], () => {
console.log(`Development connected successfully ON PORT-${process.argv[2]}`);
});
} else {
httpServer.listen(port, () => {
console.log(`Production connected successfully ON port-${port}`);
});
}
module.exports = httpServer;