nestjs-request-response-logger
v1.0.8
Published
NestJS module to log request/response to mysql database
Downloads
11
Readme
NestJS Module - Logging Request And Response
Description
This is NestJS Module which use for logging request and response of an api
How to use
- Install
npm i --save nestjs-request-response-logger
- Config
@Module({
imports: [
RequestResponseLoggerModule.register(),
],
controllers: [AppController],
providers: [],
exports: []
})
export class AppModule implements NestModule {}
- Setup Database
CREATE TABLE `request_log` (
`id` int NOT NULL AUTO_INCREMENT,
`tokenUserId` int DEFAULT NULL,
`agent` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`token` text COLLATE utf8mb4_unicode_ci,
`method` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`url` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`query` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`params` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`body` text COLLATE utf8mb4_unicode_ci,
`response_code` int DEFAULT NULL,
`response_data` text COLLATE utf8mb4_unicode_ci,
`error` text COLLATE utf8mb4_unicode_ci,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
- Author
Tran Hieu Dao