-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathapp.js
More file actions
38 lines (33 loc) · 1010 Bytes
/
app.js
File metadata and controls
38 lines (33 loc) · 1010 Bytes
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
var express = require('express');
var bodyParser = require('body-parser');
var compress = require('compression');
var renderer = require('./routes/renderer');
var cors = require('cors');
var app = express();
app.use(cors());
app.use(compress());
app.use(bodyParser.json({limit: '100mb'}));
app.use(bodyParser.urlencoded({ extended: false }));
app.use('/', renderer);
app.use(function(req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});
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+= ' <h2>More information: lintangwisesa@ymail.com</h2>';
html+= ' <pre>'+err.stack+'</pre>';
html+= ' </body>';
html+= '</html>';
res.send(html);
});
module.exports = app;