hongbo-miao/hongbomiao.com

View on GitHub
api-node/src/log/middlewares/pinoMiddleware.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { RequestHandler } from 'express';
import pinoHTTP from 'pino-http';
import config from '../../config';
import logger from '../utils/logger';

const pinoMiddleware = (): RequestHandler => {
  return pinoHTTP({
    autoLogging: !config.shouldHideHTTPLog,
    logger,
    serializers: {
      req: (req) => {
        req.body = req.raw.body;
        return req;
      },
    },
  });
};

export default pinoMiddleware;