Use pino for production logging

master
Joe Biellik 4 years ago
parent 0152b4f460
commit 7eadbe1d0e

@ -8,8 +8,12 @@ require('./db');
app.keys = config.keys; app.keys = config.keys;
app.proxy = true; app.proxy = true;
if (process.env.NODE_ENV == 'production') { if (process.env.NODE_ENV === 'production') {
app.on('error', (err, ctx) => console.error(ctx.request.ip, ctx.request.method, ctx.request.url, err.status, err.message)); app.silent = true;
app.use(require('koa-pino-logger')({
base: null
}));
} else { } else {
app.use(require('koa-logger')()); app.use(require('koa-logger')());
} }
@ -47,13 +51,6 @@ app.use(require('koa-views')(path.join(__dirname, 'views'), {
})); }));
app.use(router.routes()); app.use(router.routes());
app.use(async (ctx, next) => {
await next();
if (!ctx.status || ctx.status == 404) ctx.throw(404);
});
app.use(router.allowedMethods()); app.use(router.allowedMethods());
module.exports = app; module.exports = app;

6556
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -34,11 +34,12 @@
"koa-etag": "^3.0.0", "koa-etag": "^3.0.0",
"koa-helmet": "^5.2.0", "koa-helmet": "^5.2.0",
"koa-logger": "^3.2.1", "koa-logger": "^3.2.1",
"koa-pino-logger": "^3.0.0",
"koa-router": "^9.1.0", "koa-router": "^9.1.0",
"koa-static-cache": "^5.1.3", "koa-static-cache": "^5.1.4",
"koa-views": "^6.3.0", "koa-views": "^6.3.0",
"mongoose": "^5.9.26", "mongoose": "^5.9.28",
"nanoid": "^3.1.11", "nanoid": "^3.1.12",
"nanoid-dictionary": "^3.0.0", "nanoid-dictionary": "^3.0.0",
"pug": "^3.0.0" "pug": "^3.0.0"
}, },

Loading…
Cancel
Save