2.0.0 • Published 3 years ago

nest-morgan v2.0.0

Weekly downloads
1,850
License
MIT
Repository
github
Last release
3 years ago

Not activly maintained!

This module is not activly maintainer. Any PR's will be reviewd/merged/released. But i don't plan to work on, or add any new functionality to this module.

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() {
    ...
  }