-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
71 lines (50 loc) · 1.64 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
'use strict';
// Module dependencies.
var express = require('express');
require('systemd');
require('autoquit');
var http = require('http');
console.log(process.env.LISTEN_FDS);
var app = express();
// Express Configuration
require('./lib/config/express')(app);
// Controllers
var api = require('./lib/controllers/api'),
user = require('./lib/controllers/models/user'),
top = require('./lib/controllers/models/top'),
mail = require('./lib/controllers/mailserver'),
index = require('./lib/controllers');
// Server Routes
app.get('/api/awesomeThings', api.awesomeThings);
//Users
app.get('/api/users', user.getUsers);
app.post('/api/user', user.createUser);
app.put('/api/user/:id',user.updateUserInfo);
//Terminals
app.get('/api/terminals', user.getTerminals);
app.post('/api/terminal', user.createTerminal);
app.put('/api/terminal/:id',user.updateTerminalInfo);
//Top
app.get('/api/tap/:userId/timestamp/:timestamp', top.checkTop);
//Synchronisation
app.get('/api/timestamp', api.timestamp);
//Mail
app.get('/api/mail/:userEmail',mail.sendMail);
//app.post('/api/user',api.)
// app.get('/partials/*', index.partials);
// app.get('/*', index.index);
// Start server
var port = process.env.PORT || 3000;
var server = http.createServer(app);
if (app.get('env') === "production") {
console.log("I am in prod");
server.autoQuit({ timeout: 1800 });
server.listen('systemd')
console.log('Express server listening on port %d in %s mode', port, app.get('env'));
} else {
server.listen(port, function () {
console.log('Express server listening on port %d in %s mode', port, app.get('env'));
});
}
// Expose app
exports = module.exports = app;