Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 1x 1x | import {Next} from '@loopback/core';
import {MiddlewareContext} from '@loopback/rest';
const log = async (middlewareCtx: MiddlewareContext, next: Next) => {
const {request} = middlewareCtx;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
try {
// Proceed with next middleware
return await next();
} catch (err) {
// Catch errors from downstream middleware
console.error(
'Error received for %s %s',
request.method,
request.originalUrl,
request.body ? JSON.stringify(request.body, null, 2) : ''
);
console.error(err);
throw err;
}
};
export default log;
|