-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
35 lines (27 loc) · 886 Bytes
/
server.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
// NETWORK CONSTANTS
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
// LOCAL CONSTANTS
const str = 'pomodore_app';
const message = require('./server/message');
const routes = require('./server/routes');
const {Users} = require('./server/users');
const pomodore = require('./server/pomodore');
// List of users currently joined in the chat
let users = new Users();
app.set('port', (process.env.PORT || 5000));
// Process application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({extended: false}));
// Process application/json
app.use(bodyParser.json());
// Setting all routes
routes.init(app, users);
// Set a clock
setInterval(() => {
pomodore.tick(users); // do this every 5 seconds
}, 5000);
// Spin up the server
app.listen(app.get('port'), function() {
console.log('running on port', app.get('port'));
});