X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=server%2Fapp.js;h=1fc03c598722a2e6f8028798539b6cc2b1fcf0a9;hp=f97d925baebc5143795e830551a888a8af3761d0;hb=dac395887d96e2d642b209c6db6aaacc3ffacb34;hpb=5fde3a01497262862afc4cb4c9457d4e0ad69a4a diff --git a/server/app.js b/server/app.js index f97d925b..1fc03c59 100644 --- a/server/app.js +++ b/server/app.js @@ -12,17 +12,17 @@ app.use(favicon(path.join(__dirname, "static", "favicon.ico"))); if (app.get('env') === 'development') { - // Full logging in development mode - app.use(logger('dev')); + // Full logging in development mode + app.use(logger('dev')); } else { - // http://dev.rdybarra.com/2016/06/23/Production-Logging-With-Morgan-In-Express/ - app.set('trust proxy', true); - // In prod, only log error responses (https://github.com/expressjs/morgan) - app.use(logger('combined', { - skip: function (req, res) { return res.statusCode < 400 } - })); + // http://dev.rdybarra.com/2016/06/23/Production-Logging-With-Morgan-In-Express/ + app.set('trust proxy', true); + // In prod, only log error responses (https://github.com/expressjs/morgan) + app.use(logger('combined', { + skip: function (req, res) { return res.statusCode < 400 } + })); } app.use(express.json()); @@ -33,14 +33,14 @@ app.use(express.static(path.join(__dirname, 'static'))); //client "prod" files // In development stage the client side has its own server if (params.cors.enable) { - app.use(function(req, res, next) { - res.header("Access-Control-Allow-Origin", params.cors.allowedOrigin); - res.header("Access-Control-Allow-Credentials", true); //for cookies + app.use(function(req, res, next) { + res.header("Access-Control-Allow-Origin", params.cors.allowedOrigin); + res.header("Access-Control-Allow-Credentials", true); //for cookies res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); - res.header("Access-Control-Allow-Methods", "GET, POST, OPTIONS, PUT, DELETE"); + res.header("Access-Control-Allow-Methods", "GET, POST, OPTIONS, PUT, DELETE"); next(); - }); + }); } // Routing (AJAX-only) @@ -60,11 +60,11 @@ app.use(function(err, req, res, next) { // render the error page res.status(err.status || 500); res.send(` - -

= message

-

= error.status

-
#{error.stack}
- `); + +

= message

+

= error.status

+
#{error.stack}
+ `); }); module.exports = app;