UNPKG

@ancxkush/create-ts-express-mongo-starter-code

Version:

NodeJS/Express starter code with - TypeScript, MongoDB setup, Exception Handler, Logger, HTTP testing example, Swagger Docs example, Mongoose model example, JOI validation example, CRUD operations example

24 lines (18 loc) 581 B
import morgan, { StreamOptions } from 'morgan' import { NODE_ENV } from '../config/env' import logger from './winstonLogger' const stream: StreamOptions = { // Use the http severity write: (message) => logger.http(message), } // Skip all the Morgan http log if the // application is not running in development mode. const skip = () => { const env = NODE_ENV || 'development' return env !== 'development' } const morganLogger = morgan( ':method :url :status :res[content-length] - :response-time ms', { stream, skip } ) export default morganLogger