You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
461 B
JavaScript
16 lines
461 B
JavaScript
10 months ago
|
const requestLogsService = require('./../services/requestLogsService');
|
||
|
const rlog = async (ctx, next) => {
|
||
|
try {
|
||
|
await next();
|
||
|
} catch (err) {
|
||
|
} finally {
|
||
|
await requestLogsService.create({
|
||
|
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,
|
||
|
});
|
||
|
}
|
||
|
};
|
||
|
module.exports = rlog;
|