-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.ts
43 lines (31 loc) · 897 Bytes
/
server.ts
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
import bodyParser from 'body-parser';
// import cors from 'cors';
import express from 'express';
import http from 'http';
// Utils
import router from './helpers/routes';
import * as socketHelper from './helpers/socket';
// Config
import config from './config';
// Db
import db from './db';
// Consts
const port = config.PORT;
// Express connection
const app = express();
app.use(bodyParser.json());
// Node Server initializing
const server = new http.Server(app);
// Db Connection
db();
// Routing Manage
router(app);
// Cors for enable request from frontend
// app.use(cors()); // Uncoment to prevent CROSS ORIGIN problems.
// Socket Connection
socketHelper.connect(server);
app.use(`/${config.PUBLIC_ROUTE}`, express.static('public'));
server.listen(port, () => {
// tslint:disable-next-line
console.log(`This app is listening in ${port}.. Go to => ${config.HOST}:${port}`);
});