Morgan Module for Nest framework
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.
This's a Morgan module for Nest.
$ npm i --save nest-morgan morgan @types/morgan
- 2.x Is for Nest v7.x
- Remove the need to use
MorganModule.forRoot()
#17.
- Remove the need to use
- 1.x Is for Nest v6.x
- 0.x Is for Nest v5.x
app.module.ts
@Module({
imports: [MorganModule],
})
export class ApplicationModule {}
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 {}
app.controller.ts
@UseInterceptors(MorganInterceptor('combined'))
@Get('/some/route')
public async someRoute() {
...
}