forked from ionic-team/ionic-site
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
43 lines (34 loc) · 1.17 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
require('dotenv').config({silent: true});
const express = require('express');
const app = express();
const compress = require('compression');
const config = require('./server/config');
const cookieParser = require('cookie-parser');
const expressNunjucks = require('express-nunjucks');
const tools = require('./server/tools');
const pageNotFound = require('./server/pageNotFound');
const processRequest = require('./server/processRequest');
const router = require('./server/router');
process.env.PWD = process.cwd();
console.log('PWD', process.env.PWD);
app.set('trust proxy', true);
app.use(compress());
app.use(cookieParser());
app.use(processRequest);
app.set('views', __dirname + '/server/pages');
expressNunjucks(app, {
noCache: !config.PROD,
autoescape: false
});
app.enable('etag');
app.use(router(app));
app.use(express.static(process.env.PWD + '/_site/', {
etag: true
}));
app.use(pageNotFound);
// bind the app to listen for connections on a specified port
app.listen(config.PORT, function() {
// Render some console log output
console.log('Listening on port ' + config.PORT);
tools.bustCloudflareCache();
});