Showing
1 changed file
with
8 additions
and
19 deletions
1 | -let createError = require('http-errors'); | 1 | +const createError = require('http-errors'); |
2 | -let express = require('express'); | 2 | +const express = require('express'); |
3 | -let path = require('path'); | 3 | +const path = require('path'); |
4 | -let cookieParser = require('cookie-parser'); | 4 | +const cookieParser = require('cookie-parser'); |
5 | -let logger = require('morgan'); | 5 | +const logger = require('morgan'); |
6 | 6 | ||
7 | -let indexRouter = require('./routes/index'); | 7 | +const indexRouter = require('./routes/index'); |
8 | 8 | ||
9 | -let app = express(); | 9 | +const app = express(); |
10 | 10 | ||
11 | // view engine setup | 11 | // view engine setup |
12 | app.set('views', path.join(__dirname, 'views')); | 12 | app.set('views', path.join(__dirname, 'views')); |
... | @@ -21,19 +21,8 @@ app.use(express.static(path.join(__dirname, 'public'))); | ... | @@ -21,19 +21,8 @@ app.use(express.static(path.join(__dirname, 'public'))); |
21 | app.use('/', indexRouter); | 21 | app.use('/', indexRouter); |
22 | 22 | ||
23 | // catch 404 and forward to error handler | 23 | // catch 404 and forward to error handler |
24 | -app.use(function(req, res, next) { | 24 | +app.use(function (req, res, next) { |
25 | next(createError(404)); | 25 | next(createError(404)); |
26 | }); | 26 | }); |
27 | 27 | ||
28 | -// error handler | ||
29 | -app.use(function(err, req, res, next) { | ||
30 | - // set locals, only providing error in development | ||
31 | - res.locals.message = err.message; | ||
32 | - res.locals.error = req.app.get('env') === 'development' ? err : {}; | ||
33 | - | ||
34 | - // render the error page | ||
35 | - res.status(err.status || 500); | ||
36 | - res.render('error'); | ||
37 | -}); | ||
38 | - | ||
39 | module.exports = app; | 28 | module.exports = app; | ... | ... |
-
Please register or login to post a comment