-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
38 lines (27 loc) · 857 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
36
37
38
const express = require( 'express' );
const nunjucks = require('nunjucks');
const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');
var program = require('commander');
const routes = require("./controllers/routes");
program.version("0.2")
.option("-d, --dev", "Development mode: server listens on port 8080")
.parse(process.argv);
var DEV_MODE = false;
if(program.dev) DEV_MODE = true;
var app = express();
/**
* Initialisation routine
*/
nunjucks.configure(['templates'], {
autoescape: true,
express: app
});
app.use(cookieParser());
app.use(bodyParser.urlencoded({limit: '50mb', extended: false }));
app.use(bodyParser.json({limit: '50mb'}));
app.use(routes);
var _port = 8001;
if(DEV_MODE) _port = 8080;
app.listen( _port );
console.log(`DEV_MODE = ${DEV_MODE}, server listening on port ${_port}`);