const { createRequestLog } = require('../../services/request_logs.service'); module.exports = async (ctx, next) => { try { await next(); } catch (err) { } finally { await createRequestLog({ method: ctx.method, path: ctx.method === 'GET' ? ctx.path : ctx.url, request_data: ctx.method === 'GET' ? JSON.stringify(ctx.query) : JSON.stringify(ctx.request.body), ip: ctx.ip, }); } };