Skip to content

Commit

Permalink
logger: bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ntzyz committed Sep 20, 2018
1 parent b2c6ed5 commit 19665bc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions utils/logger.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const websocket = require('./websocket');
const utils = require('../utils');
const db = require('./db');

/**
* Activity logger middleware.
* @param {Request} req
* @param {Response} res
* @param {Function} next
*/
function logger (req, res, next) {
async function logger (req, res, next) {
if (req.headers['server-side-rendering'] === 'true') {
return next();
}
Expand All @@ -27,8 +27,9 @@ function logger (req, res, next) {
websocket.io.emit('log', message);

// Write log to database
await db.prepare();
// We do NOT need to await here.
utils.db.conn.collection('logs').insert({
db.conn.collection('logs').insert({
time: new Date(),
ip: req.headers['x-real-ip'] || req.ip || '0.0.0.0',
method: req.method,
Expand Down

0 comments on commit 19665bc

Please sign in to comment.