1 var createError
= require('http-errors');
2 var express
= require('express');
3 var path
= require('path');
4 var cookieParser
= require('cookie-parser');
5 var logger
= require('morgan');
6 var sassMiddleware
= require('node-sass-middleware');
7 var favicon
= require('serve-favicon');
9 var router
= require('./routes/all');
13 app
.use(favicon(path
.join(__dirname
, "public", "images", "favicon", "favicon.ico")));
15 if (app
.get('env') === 'development')
17 // Full logging in development mode
18 app
.use(logger('dev'));
22 // http://dev.rdybarra.com/2016/06/23/Production-Logging-With-Morgan-In-Express/
23 app
.set('trust proxy', true);
24 // In prod, only log error responses (https://github.com/expressjs/morgan)
25 app
.use(logger('combined', {
26 skip: function (req
, res
) { return res
.statusCode
< 400 }
30 // Allow layout.pug to select the right vue file:
31 app
.locals
.development
= app
.get('env') === 'development';
34 app
.set('views', path
.join(__dirname
, 'views'));
35 app
.set('view engine', 'pug');
37 app
.use(express
.json());
38 app
.use(express
.urlencoded({ extended: false }));
39 app
.use(cookieParser());
40 app
.use(sassMiddleware({
41 src: path
.join(__dirname
, 'public'),
42 dest: path
.join(__dirname
, 'public'),
43 indentedSyntax: true, // true = .sass and false = .scss
46 app
.use(express
.static(path
.join(__dirname
, 'public')));
50 // catch 404 and forward to error handler
51 app
.use(function(req
, res
, next
) {
52 next(createError(404));
56 app
.use(function(err
, req
, res
, next
) {
57 // set locals, only providing error in development
58 res
.locals
.message
= err
.message
;
59 res
.locals
.error
= req
.app
.get('env') === 'development' ? err : {};
60 // render the error page
61 res
.status(err
.status
|| 500);