Skip to content
This repository has been archived by the owner on Jul 8, 2021. It is now read-only.

Latest commit

 

History

History
84 lines (62 loc) · 2.28 KB

README.md

File metadata and controls

84 lines (62 loc) · 2.28 KB

Nest Logo

Morgan Module for Nest framework

NPM Version Package License NPM Downloads Github Actions - Test

NOT MAINTAINED!

Hey all. This project is not maintained and archived. You should check out iamolegga/nestjs-pino which is maintained and with a bunch of cool features.

Description

This's a Morgan module for Nest.

Installation

$ npm i --save nest-morgan morgan @types/morgan

Versions

  • 2.x Is for Nest v7.x
    • Remove the need to use MorganModule.forRoot() #17.
  • 1.x Is for Nest v6.x
  • 0.x Is for Nest v5.x

Quick Start

Include Module

app.module.ts

@Module({
  imports: [MorganModule],
})
export class ApplicationModule {}

Global

If you want to set up interceptor as global, you have to follow Nest instructions here. Something like this:

app.module.ts

import { Module } from "@nestjs/common";
import { APP_INTERCEPTOR } from "@nestjs/core";
import { MorganModule, MorganInterceptor } from "nest-morgan";

@Module({
  imports: [MorganModule],
  providers: [
    {
      provide: APP_INTERCEPTOR,
      useClass: MorganInterceptor("combined"),
    },
  ],
})
export class ApplicationModule {}

Using Interceptor

app.controller.ts

  @UseInterceptors(MorganInterceptor('combined'))
  @Get('/some/route')
  public async someRoute() {
    ...
  }