-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathserver.js
28 lines (22 loc) · 847 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
const express = require("express");
const compression = require("compression");
require("./webpack.config.js"); // So that webpack lints itself
const app = express();
// Accept JSON as req.body
const bodyParser = require("body-parser");
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(compression());
app.set('view engine', 'ejs');
const router = require('./routes')();
app.use('/', router);
// Add an explicit no-cache to 404 responses
// Since this is the last handler it will only be hit when all other handlers miss
app.use(function(req, res, next) {
res.header("Cache-Control", "no-cache, no-store, must-revalidate");
return next();
});
// Listen on App port
var listener = app.listen(process.env.PORT, () => {
console.log(`Your app is listening on port ${listener.address().port}.`);
});