Customize logging and add distinction for dev/prod

pull/1/head
Florian Hartwich 2017-05-17 02:28:51 +02:00
parent f6037a1913
commit be12e756a0
1 changed files with 10 additions and 5 deletions

View File

@ -48,19 +48,24 @@ app.use(favicon(path.join(__dirname + '/..', 'public', 'favicon.ico')));
app.use(express.static(path.join(__dirname + '/..', 'public')));
app.use(bodyParser.json());
// logging
if (process.env.NODE_ENV !== config.test.env) {
app.use(requestLogger('dev'));
}
// API request checks for API-version and JSON etc.
app.use(restAPIchecks);
// Routes ******************************************************
app.use(urls.auth, authenticateRouter);
app.use(urls.signatures, signatureRouter);
// initialize logging here to exclude /signature requests
if (!process.env.NODE_ENV) {
// development logging
app.use(requestLogger('dev'));
} else if (process.env.NODE_ENV !== config.test.env) {
// production logging, apache style
app.use(requestLogger(':date :remote-addr :method :url :status :response-time ms'));
}
app.use(urls.auth, authenticateRouter);
app.use(urls.overview, overviewRouter);
app.use(urls.users, userRouter);
app.use(urls.squads, squadRouter);