Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mentos1386/nest-morgan
Morgan Logger for Nestjs
https://github.com/mentos1386/nest-morgan
logging morgan nest nest-module typescript
Last synced: about 1 month ago
JSON representation
Morgan Logger for Nestjs
- Host: GitHub
- URL: https://github.com/mentos1386/nest-morgan
- Owner: mentos1386
- License: mit
- Archived: true
- Created: 2018-07-14T19:25:05.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-07-08T09:50:59.000Z (over 3 years ago)
- Last Synced: 2024-10-25T17:38:41.917Z (about 2 months ago)
- Topics: logging, morgan, nest, nest-module, typescript
- Language: TypeScript
- Size: 302 KB
- Stars: 19
- Watchers: 4
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-nestjs - Nest Morgan - 用于 nestjs 的 Morgan 模块 (资源 / 组件和库)
README
Morgan Module for Nest framework
### NOT MAINTAINED!
Hey all. **This project is not maintained and archived.** You should check out [iamolegga/nestjs-pino](https://github.com/iamolegga/nestjs-pino) which is maintained
and with a bunch of cool features.## Description
This's a [Morgan](https://github.com/expressjs/morgan) module for [Nest](https://github.com/nestjs/nest).
## Installation
```bash
$ npm i --save nest-morgan morgan @types/morgan
```### Versions
- **2.x** Is for Nest v7.x
- Remove the need to use `MorganModule.forRoot()` [#17](https://github.com/mentos1386/nest-morgan/issues/17).
- **1.x** Is for Nest v6.x
- **0.x** Is for Nest v5.x## Quick Start
### Include Module
> app.module.ts
```ts
@Module({
imports: [MorganModule],
})
export class ApplicationModule {}
```#### Global
If you want to set up interceptor as global, you have to follow Nest
instructions [here](https://docs.nestjs.com/interceptors). Something like
this:> app.module.ts
```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
```ts
@UseInterceptors(MorganInterceptor('combined'))
@Get('/some/route')
public async someRoute() {
...
}
```