-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathapp.js
More file actions
41 lines (34 loc) · 1 KB
/
app.js
File metadata and controls
41 lines (34 loc) · 1 KB
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
// basic setup requirements
var express = require('express');
var bodyParser = require('body-parser');
var compress = require('compression');
var app = express();
var renderer = require('./routes/renderer');
app.use(compress());
app.use(bodyParser.json({limit: '100mb'}));
app.use(bodyParser.urlencoded({ extended: false }));
app.use('/', renderer);
// catch 404 and forward to error handler
app.use(function(req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});
// production error handler
// no stacktraces leaked to user
app.use(function(err, req, res, next) {
res.status(err.status || 500);
var html = '<!DOCTYPE html>';
html+= '<html>';
html+= ' <head>';
html+= ' <title></title>';
html+= ' </head>';
html+= ' <body>';
html+= ' <h1>'+err.message+'</h1>';
html+= ' <h2>'+err.status+'</h2>';
html+= ' <pre>'+err.stack+'</pre>';
html+= ' </body>';
html+= '</html>';
res.send(html);
});
module.exports = app;