-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
39 lines (30 loc) · 913 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
38
39
'use strict';
// brew services start mongodb-community
const express = require('express');
const http = require('http');
const io = require('socket.io');
const routeslib = require('./routes');
const socketlib = require('./socket');
const dblib = require('./db');
const dotenv = require('dotenv');
class Server {
constructor() {
dotenv.config();
this.app = express();
this.http = http.createServer(this.app);
this.socket = io(this.http);
this.db = new dblib();
this.app.use(express.static('public'))
}
//
start() {
new routeslib(this.app,this.db).create();
new socketlib(this.socket, this.db).create();
const PORT = process.env.PORT || 3000;
this.http.listen(PORT, () => {
console.log('Listening on *:'+PORT);
});
}
}
const app = new Server();
app.start();