forked from bodyno/front-end-separate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
37 lines (29 loc) · 941 Bytes
/
app.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
var express = require('express');
var path = require('path');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var routes = require('./routes/routes');
var ms=require("ms");
var nunjucks=require("nunjucks");
var compression = require('compression')
var config=require("./config/config");
var app = express();
var dir=app.get('env')=="production"?"dist":"app";
app.set('view engine', 'html');
nunjucks.configure(__dirname + "/"+dir+"/views", {
autoescape: true,
express: app,
watch: true
});
app.use(compression());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
app.use(express.static(path.join(__dirname + "/"+dir),{
maxAge:ms("7d")
}));
routes(app);
app.set('port', config.port.www);
var server = app.listen(app.get('port'), function() {
console.log('Express server listening on port ' + server.address().port);
});