How to return properly using async in this code

So i have this code const log = require("./queries/logQuery"); const moment = require(‘moment’); const morgan = require(‘morgan’); const custom = async (tokens, req, res) => { if(req.session){ if(req.session.superadmin){ const date = moment().locale(‘id’).format(‘DD-MM-YYYY HH:mm:ss’); const usr = req.session.superadmin; const method = tokens.method(req, res); const endpoint = tokens.url(req, res); const statusCode = tokens.status(req, res); await log.addLog(date, usr,… Read More How to return properly using async in this code

Creating logger middleware using morgan

I would like to create a middleware using morgan, i tryed to export the middleware function, then require in app.js. I don’t kown why this is not working Middleware: const morgan = require(‘morgan’); const rfs = require("rotating-file-stream"); const rfsStream = rfs.createStream("logs/log.txt", { size: ’10M’, // rotate every 10 MegaBytes written interval: ‘1d’, // rotate daily… Read More Creating logger middleware using morgan