@tc-libs/http-log 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/package.json +11 -0
- package/src/constants/http-log.contants.d.ts +1 -0
- package/src/constants/http-log.contants.js +5 -0
- package/src/constants/http-log.contants.js.map +1 -0
- package/src/constants/index.d.ts +3 -0
- package/src/constants/index.js +7 -0
- package/src/constants/index.js.map +1 -0
- package/src/constants/logger.constant.d.ts +2 -0
- package/src/constants/logger.constant.js +6 -0
- package/src/constants/logger.constant.js.map +1 -0
- package/src/constants/logger.enum.constant.d.ts +6 -0
- package/src/constants/logger.enum.constant.js +11 -0
- package/src/constants/logger.enum.constant.js.map +1 -0
- package/src/decorators/logger.decorator.d.ts +2 -0
- package/src/decorators/logger.decorator.js +10 -0
- package/src/decorators/logger.decorator.js.map +1 -0
- package/src/dtos/logger.create.dto.d.ts +21 -0
- package/src/dtos/logger.create.dto.js +10 -0
- package/src/dtos/logger.create.dto.js.map +1 -0
- package/src/http-log.middleware.d.ts +47 -0
- package/src/http-log.middleware.js +130 -0
- package/src/http-log.middleware.js.map +1 -0
- package/src/http-log.module.d.ts +7 -0
- package/src/http-log.module.js +44 -0
- package/src/http-log.module.js.map +1 -0
- package/src/http-log.module.options.d.ts +13 -0
- package/src/http-log.module.options.js +5 -0
- package/src/http-log.module.options.js.map +1 -0
- package/src/index.d.ts +7 -0
- package/src/index.js +11 -0
- package/src/index.js.map +1 -0
- package/src/interceptors/logger.interceptor.d.ts +10 -0
- package/src/interceptors/logger.interceptor.js +55 -0
- package/src/interceptors/logger.interceptor.js.map +1 -0
- package/src/interfaces/logger.interface.d.ts +6 -0
- package/src/interfaces/logger.interface.js +3 -0
- package/src/interfaces/logger.interface.js.map +1 -0
- package/src/interfaces/logger.service.interface.d.ts +9 -0
- package/src/interfaces/logger.service.interface.js +3 -0
- package/src/interfaces/logger.service.interface.js.map +1 -0
- package/src/logger.module.d.ts +2 -0
- package/src/logger.module.js +19 -0
- package/src/logger.module.js.map +1 -0
- package/src/repository/entities/logger.entity.d.ts +26 -0
- package/src/repository/entities/logger.entity.js +127 -0
- package/src/repository/entities/logger.entity.js.map +1 -0
- package/src/repository/logger.repository.module.d.ts +2 -0
- package/src/repository/logger.repository.module.js +27 -0
- package/src/repository/logger.repository.module.js.map +1 -0
- package/src/repository/repositories/logger.repository.d.ts +11 -0
- package/src/repository/repositories/logger.repository.js +28 -0
- package/src/repository/repositories/logger.repository.js.map +1 -0
- package/src/services/logger.service.d.ts +13 -0
- package/src/services/logger.service.js +110 -0
- package/src/services/logger.service.js.map +1 -0
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DEBUGGER_HTTP_FORMAT = "':remote-addr' - ':remote-user' - '[:date[iso]]' - 'HTTP/:http-version' - '[:status]' - ':method' - ':url' - 'Request Header :: :req-headers' - 'Request Params :: :req-params' - 'Request Body :: :req-body' - 'Response Header :: :res[header]' - 'Response Body :: :res-body' - ':response-time ms' - ':referrer' - ':user-agent'";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEBUGGER_HTTP_FORMAT = void 0;
|
|
4
|
+
exports.DEBUGGER_HTTP_FORMAT = "':remote-addr' - ':remote-user' - '[:date[iso]]' - 'HTTP/:http-version' - '[:status]' - ':method' - ':url' - 'Request Header :: :req-headers' - 'Request Params :: :req-params' - 'Request Body :: :req-body' - 'Response Header :: :res[header]' - 'Response Body :: :res-body' - ':response-time ms' - ':referrer' - ':user-agent'";
|
|
5
|
+
//# sourceMappingURL=http-log.contants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-log.contants.js","sourceRoot":"","sources":["../../../../../packages/http-log/src/constants/http-log.contants.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAC/B,sUAAsU,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./http-log.contants"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./logger.constant"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./logger.enum.constant"), exports);
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/http-log/src/constants/index.ts"],"names":[],"mappings":";;;AAAA,8DAAoC;AACpC,4DAAkC;AAClC,iEAAuC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LOGGER_OPTIONS_META_KEY = exports.LOGGER_ACTION_META_KEY = void 0;
|
|
4
|
+
exports.LOGGER_ACTION_META_KEY = 'LoggerActionMetaKey';
|
|
5
|
+
exports.LOGGER_OPTIONS_META_KEY = 'LoggerOptionsMetaKey';
|
|
6
|
+
//# sourceMappingURL=logger.constant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.constant.js","sourceRoot":"","sources":["../../../../../packages/http-log/src/constants/logger.constant.ts"],"names":[],"mappings":";;;AAAa,QAAA,sBAAsB,GAAG,qBAAqB,CAAC;AAC/C,QAAA,uBAAuB,GAAG,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ENUM_LOGGER_LEVEL = void 0;
|
|
4
|
+
var ENUM_LOGGER_LEVEL;
|
|
5
|
+
(function (ENUM_LOGGER_LEVEL) {
|
|
6
|
+
ENUM_LOGGER_LEVEL["DEBUG"] = "DEBUG";
|
|
7
|
+
ENUM_LOGGER_LEVEL["INFO"] = "INFO";
|
|
8
|
+
ENUM_LOGGER_LEVEL["WARM"] = "WARM";
|
|
9
|
+
ENUM_LOGGER_LEVEL["FATAL"] = "FATAL";
|
|
10
|
+
})(ENUM_LOGGER_LEVEL || (exports.ENUM_LOGGER_LEVEL = ENUM_LOGGER_LEVEL = {}));
|
|
11
|
+
//# sourceMappingURL=logger.enum.constant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.enum.constant.js","sourceRoot":"","sources":["../../../../../packages/http-log/src/constants/logger.enum.constant.ts"],"names":[],"mappings":";;;AAAA,IAAY,iBAKX;AALD,WAAY,iBAAiB;IAC3B,oCAAe,CAAA;IACf,kCAAa,CAAA;IACb,kCAAa,CAAA;IACb,oCAAe,CAAA;AACjB,CAAC,EALW,iBAAiB,iCAAjB,iBAAiB,QAK5B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Logger = Logger;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const logger_constant_1 = require("../constants/logger.constant");
|
|
6
|
+
const logger_interceptor_1 = require("../interceptors/logger.interceptor");
|
|
7
|
+
function Logger(action, options) {
|
|
8
|
+
return (0, common_1.applyDecorators)((0, common_1.UseInterceptors)(logger_interceptor_1.LoggerInterceptor), (0, common_1.SetMetadata)(logger_constant_1.LOGGER_ACTION_META_KEY, action), (0, common_1.SetMetadata)(logger_constant_1.LOGGER_OPTIONS_META_KEY, options ?? {}));
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=logger.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.decorator.js","sourceRoot":"","sources":["../../../../../packages/http-log/src/decorators/logger.decorator.ts"],"names":[],"mappings":";;AAQA,wBASC;AAjBD,2CAA+E;AAC/E,kEAGsC;AACtC,2EAAuE;AAGvE,SAAgB,MAAM,CACpB,MAAc,EACd,OAAwB;IAExB,OAAO,IAAA,wBAAe,EACpB,IAAA,wBAAe,EAAC,sCAAiB,CAAC,EAClC,IAAA,oBAAW,EAAC,wCAAsB,EAAE,MAAM,CAAC,EAC3C,IAAA,oBAAW,EAAC,yCAAuB,EAAE,OAAO,IAAI,EAAE,CAAC,CACpD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ENUM_AUTH_ACCESS_FOR } from '@tc-libs/authentication';
|
|
2
|
+
import { ENUM_REQUEST_METHOD } from '@tc-libs/request';
|
|
3
|
+
import { ENUM_LOGGER_LEVEL } from '../constants/logger.enum.constant';
|
|
4
|
+
export declare class LoggerCreateDto {
|
|
5
|
+
apiKey?: string;
|
|
6
|
+
action: string;
|
|
7
|
+
description: string;
|
|
8
|
+
user?: string;
|
|
9
|
+
requestId?: string;
|
|
10
|
+
method: ENUM_REQUEST_METHOD;
|
|
11
|
+
path: string;
|
|
12
|
+
role?: string;
|
|
13
|
+
accessFor?: ENUM_AUTH_ACCESS_FOR;
|
|
14
|
+
tags?: string[];
|
|
15
|
+
params?: Record<string, any>;
|
|
16
|
+
bodies?: Record<string, any>;
|
|
17
|
+
statusCode?: number;
|
|
18
|
+
}
|
|
19
|
+
export declare class LoggerCreateRawDto extends LoggerCreateDto {
|
|
20
|
+
level: ENUM_LOGGER_LEVEL;
|
|
21
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LoggerCreateRawDto = exports.LoggerCreateDto = void 0;
|
|
4
|
+
class LoggerCreateDto {
|
|
5
|
+
}
|
|
6
|
+
exports.LoggerCreateDto = LoggerCreateDto;
|
|
7
|
+
class LoggerCreateRawDto extends LoggerCreateDto {
|
|
8
|
+
}
|
|
9
|
+
exports.LoggerCreateRawDto = LoggerCreateRawDto;
|
|
10
|
+
//# sourceMappingURL=logger.create.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.create.dto.js","sourceRoot":"","sources":["../../../../../packages/http-log/src/dtos/logger.create.dto.ts"],"names":[],"mappings":";;;AAIA,MAAa,eAAe;CAc3B;AAdD,0CAcC;AAED,MAAa,kBAAmB,SAAQ,eAAe;CAEtD;AAFD,gDAEC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { NestMiddleware } from '@nestjs/common';
|
|
2
|
+
import { RotatingFileStream } from 'rotating-file-stream';
|
|
3
|
+
import { Request, Response, NextFunction } from 'express';
|
|
4
|
+
import { DateService } from '@tc-libs/helper';
|
|
5
|
+
import { HttpLogModuleOptions } from './http-log.module.options';
|
|
6
|
+
export interface IDebuggerHttpConfigOptions {
|
|
7
|
+
readonly stream: RotatingFileStream;
|
|
8
|
+
}
|
|
9
|
+
export interface IDebuggerHttpConfig {
|
|
10
|
+
readonly debuggerHttpFormat: string;
|
|
11
|
+
readonly debuggerHttpOptions?: IDebuggerHttpConfigOptions;
|
|
12
|
+
}
|
|
13
|
+
export interface IDebuggerHttpMiddleware extends Response {
|
|
14
|
+
body: string;
|
|
15
|
+
}
|
|
16
|
+
export declare class HttpLogMiddleware implements NestMiddleware {
|
|
17
|
+
private readonly _options;
|
|
18
|
+
private readonly writeIntoFile;
|
|
19
|
+
private readonly writeIntoConsole;
|
|
20
|
+
constructor(_options: HttpLogModuleOptions);
|
|
21
|
+
private customToken;
|
|
22
|
+
use(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
export declare class HttpLogWriteIntoFileMiddleware implements NestMiddleware {
|
|
25
|
+
private readonly _options;
|
|
26
|
+
private readonly helperDateService;
|
|
27
|
+
private readonly writeIntoFile;
|
|
28
|
+
private readonly maxSize;
|
|
29
|
+
private readonly maxFiles;
|
|
30
|
+
constructor(_options: HttpLogModuleOptions, helperDateService: DateService);
|
|
31
|
+
private httpLogger;
|
|
32
|
+
use(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
export declare class HttpLogWriteIntoConsoleMiddleware implements NestMiddleware {
|
|
35
|
+
private readonly _options;
|
|
36
|
+
private readonly writeIntoConsole;
|
|
37
|
+
constructor(_options: HttpLogModuleOptions);
|
|
38
|
+
private httpLogger;
|
|
39
|
+
use(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
export declare class HttpLogResponseMiddleware implements NestMiddleware {
|
|
42
|
+
private readonly _options;
|
|
43
|
+
private readonly writeIntoFile;
|
|
44
|
+
private readonly writeIntoConsole;
|
|
45
|
+
constructor(_options: HttpLogModuleOptions);
|
|
46
|
+
use(req: Request, res: Response, next: NextFunction): void;
|
|
47
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpLogResponseMiddleware = exports.HttpLogWriteIntoConsoleMiddleware = exports.HttpLogWriteIntoFileMiddleware = exports.HttpLogMiddleware = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const morgan_1 = tslib_1.__importDefault(require("morgan"));
|
|
7
|
+
const rotating_file_stream_1 = require("rotating-file-stream");
|
|
8
|
+
const helper_1 = require("@tc-libs/helper");
|
|
9
|
+
const http_log_contants_1 = require("./constants/http-log.contants");
|
|
10
|
+
const http_log_module_options_1 = require("./http-log.module.options");
|
|
11
|
+
let HttpLogMiddleware = class HttpLogMiddleware {
|
|
12
|
+
constructor(_options) {
|
|
13
|
+
this._options = _options;
|
|
14
|
+
this.writeIntoFile = _options.http.writeIntoFile;
|
|
15
|
+
this.writeIntoConsole = _options.http.writeIntoConsole;
|
|
16
|
+
}
|
|
17
|
+
customToken() {
|
|
18
|
+
morgan_1.default.token('req-params', (req) => JSON.stringify(req.params));
|
|
19
|
+
morgan_1.default.token('req-body', (req) => JSON.stringify(req.body));
|
|
20
|
+
morgan_1.default.token('res-body', (req, res) => res.body);
|
|
21
|
+
morgan_1.default.token('req-headers', (req) => JSON.stringify(req.headers));
|
|
22
|
+
}
|
|
23
|
+
async use(req, res, next) {
|
|
24
|
+
if (this.writeIntoConsole || this.writeIntoFile) {
|
|
25
|
+
this.customToken();
|
|
26
|
+
}
|
|
27
|
+
next();
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
exports.HttpLogMiddleware = HttpLogMiddleware;
|
|
31
|
+
exports.HttpLogMiddleware = HttpLogMiddleware = tslib_1.__decorate([
|
|
32
|
+
(0, common_1.Injectable)(),
|
|
33
|
+
tslib_1.__param(0, (0, common_1.Inject)(http_log_module_options_1.HTTP_LOG_CONFIG_OPTIONS)),
|
|
34
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
35
|
+
], HttpLogMiddleware);
|
|
36
|
+
let HttpLogWriteIntoFileMiddleware = class HttpLogWriteIntoFileMiddleware {
|
|
37
|
+
constructor(_options, helperDateService) {
|
|
38
|
+
this._options = _options;
|
|
39
|
+
this.helperDateService = helperDateService;
|
|
40
|
+
this.writeIntoFile = _options.http.writeIntoFile;
|
|
41
|
+
this.maxFiles = _options.http.maxFiles;
|
|
42
|
+
this.maxSize = _options.http.maxSize;
|
|
43
|
+
}
|
|
44
|
+
async httpLogger() {
|
|
45
|
+
const date = this.helperDateService.format(this.helperDateService.create());
|
|
46
|
+
const debuggerHttpOptions = {
|
|
47
|
+
stream: (0, rotating_file_stream_1.createStream)(`${date}.log`, {
|
|
48
|
+
path: `./logs/http/`,
|
|
49
|
+
maxSize: this.maxSize,
|
|
50
|
+
maxFiles: this.maxFiles,
|
|
51
|
+
compress: true,
|
|
52
|
+
interval: '1d',
|
|
53
|
+
}),
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
debuggerHttpFormat: http_log_contants_1.DEBUGGER_HTTP_FORMAT,
|
|
57
|
+
debuggerHttpOptions,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
async use(req, res, next) {
|
|
61
|
+
if (this.writeIntoFile) {
|
|
62
|
+
const config = await this.httpLogger();
|
|
63
|
+
(0, morgan_1.default)(config.debuggerHttpFormat, config.debuggerHttpOptions)(req, res, next);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
next();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
exports.HttpLogWriteIntoFileMiddleware = HttpLogWriteIntoFileMiddleware;
|
|
71
|
+
exports.HttpLogWriteIntoFileMiddleware = HttpLogWriteIntoFileMiddleware = tslib_1.__decorate([
|
|
72
|
+
(0, common_1.Injectable)(),
|
|
73
|
+
tslib_1.__param(0, (0, common_1.Inject)(http_log_module_options_1.HTTP_LOG_CONFIG_OPTIONS)),
|
|
74
|
+
tslib_1.__metadata("design:paramtypes", [Object, helper_1.DateService])
|
|
75
|
+
], HttpLogWriteIntoFileMiddleware);
|
|
76
|
+
let HttpLogWriteIntoConsoleMiddleware = class HttpLogWriteIntoConsoleMiddleware {
|
|
77
|
+
constructor(_options) {
|
|
78
|
+
this._options = _options;
|
|
79
|
+
this.writeIntoConsole = _options.http.writeIntoConsole;
|
|
80
|
+
}
|
|
81
|
+
async httpLogger() {
|
|
82
|
+
return {
|
|
83
|
+
debuggerHttpFormat: http_log_contants_1.DEBUGGER_HTTP_FORMAT,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
async use(req, res, next) {
|
|
87
|
+
if (this.writeIntoConsole) {
|
|
88
|
+
const config = await this.httpLogger();
|
|
89
|
+
(0, morgan_1.default)(config.debuggerHttpFormat)(req, res, next);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
next();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
exports.HttpLogWriteIntoConsoleMiddleware = HttpLogWriteIntoConsoleMiddleware;
|
|
97
|
+
exports.HttpLogWriteIntoConsoleMiddleware = HttpLogWriteIntoConsoleMiddleware = tslib_1.__decorate([
|
|
98
|
+
(0, common_1.Injectable)(),
|
|
99
|
+
tslib_1.__param(0, (0, common_1.Inject)(http_log_module_options_1.HTTP_LOG_CONFIG_OPTIONS)),
|
|
100
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
101
|
+
], HttpLogWriteIntoConsoleMiddleware);
|
|
102
|
+
let HttpLogResponseMiddleware = class HttpLogResponseMiddleware {
|
|
103
|
+
constructor(_options) {
|
|
104
|
+
this._options = _options;
|
|
105
|
+
this.writeIntoFile = _options.http.writeIntoFile;
|
|
106
|
+
this.writeIntoConsole = _options.http.writeIntoConsole;
|
|
107
|
+
}
|
|
108
|
+
use(req, res, next) {
|
|
109
|
+
if (this.writeIntoConsole || this.writeIntoFile) {
|
|
110
|
+
const send = res.send;
|
|
111
|
+
const resOld = res;
|
|
112
|
+
// Add response data to request
|
|
113
|
+
// this is for morgan
|
|
114
|
+
resOld.send = (body) => {
|
|
115
|
+
resOld.body = body;
|
|
116
|
+
resOld.send = send;
|
|
117
|
+
resOld.send(body);
|
|
118
|
+
res = resOld;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
next();
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
exports.HttpLogResponseMiddleware = HttpLogResponseMiddleware;
|
|
125
|
+
exports.HttpLogResponseMiddleware = HttpLogResponseMiddleware = tslib_1.__decorate([
|
|
126
|
+
(0, common_1.Injectable)(),
|
|
127
|
+
tslib_1.__param(0, (0, common_1.Inject)(http_log_module_options_1.HTTP_LOG_CONFIG_OPTIONS)),
|
|
128
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
129
|
+
], HttpLogResponseMiddleware);
|
|
130
|
+
//# sourceMappingURL=http-log.middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-log.middleware.js","sourceRoot":"","sources":["../../../../packages/http-log/src/http-log.middleware.ts"],"names":[],"mappings":";;;;AAAA,2CAAoE;AACpE,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EAAE,CAAC;YAChD,MAAM,IAAI,GAAQ,GAAG,CAAC,IAAI,CAAC;YAC3B,MAAM,MAAM,GAAQ,GAAG,CAAC;YAExB,+BAA+B;YAC/B,qBAAqB;YACrB,MAAM,CAAC,IAAI,GAAG,CAAC,IAAS,EAAE,EAAE;gBAC1B,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;gBACnB,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;gBACnB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAElB,GAAG,GAAG,MAAkB,CAAC;YAC3B,CAAC,CAAC;QACJ,CAAC;QAED,IAAI,EAAE,CAAC;IACT,CAAC;CACF,CAAA;AA7BY,8DAAyB;oCAAzB,yBAAyB;IADrC,IAAA,mBAAU,GAAE;IAMR,mBAAA,IAAA,eAAM,EAAC,iDAAuB,CAAC,CAAA;;GALvB,yBAAyB,CA6BrC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DynamicModule, MiddlewareConsumer, NestModule } from '@nestjs/common';
|
|
2
|
+
import HttpLogModuleAsyncOptions, { HttpLogModuleOptions } from './http-log.module.options';
|
|
3
|
+
export declare class HttpLogModule implements NestModule {
|
|
4
|
+
static register(options: HttpLogModuleOptions, isGlobal?: boolean): DynamicModule;
|
|
5
|
+
static registerAsync(options: HttpLogModuleAsyncOptions, isGlobal?: boolean): DynamicModule;
|
|
6
|
+
configure(consumer: MiddlewareConsumer): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var HttpLogModule_1;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.HttpLogModule = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const common_1 = require("@nestjs/common");
|
|
7
|
+
const http_log_middleware_1 = require("./http-log.middleware");
|
|
8
|
+
const http_log_module_options_1 = require("./http-log.module.options");
|
|
9
|
+
let HttpLogModule = HttpLogModule_1 = class HttpLogModule {
|
|
10
|
+
static register(options, isGlobal) {
|
|
11
|
+
return {
|
|
12
|
+
module: HttpLogModule_1,
|
|
13
|
+
imports: [],
|
|
14
|
+
providers: [{ provide: http_log_module_options_1.HTTP_LOG_CONFIG_OPTIONS, useValue: options }],
|
|
15
|
+
exports: [],
|
|
16
|
+
global: isGlobal,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
static registerAsync(options, isGlobal) {
|
|
20
|
+
return {
|
|
21
|
+
module: HttpLogModule_1,
|
|
22
|
+
imports: [...(options.imports || [])],
|
|
23
|
+
providers: [
|
|
24
|
+
{
|
|
25
|
+
provide: http_log_module_options_1.HTTP_LOG_CONFIG_OPTIONS,
|
|
26
|
+
useFactory: options.useFactory,
|
|
27
|
+
inject: options.inject,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
exports: [],
|
|
31
|
+
global: isGlobal,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
configure(consumer) {
|
|
35
|
+
consumer
|
|
36
|
+
.apply(http_log_middleware_1.HttpLogResponseMiddleware, http_log_middleware_1.HttpLogMiddleware, http_log_middleware_1.HttpLogWriteIntoConsoleMiddleware, http_log_middleware_1.HttpLogWriteIntoFileMiddleware)
|
|
37
|
+
.forRoutes('*');
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
exports.HttpLogModule = HttpLogModule;
|
|
41
|
+
exports.HttpLogModule = HttpLogModule = HttpLogModule_1 = tslib_1.__decorate([
|
|
42
|
+
(0, common_1.Module)({ imports: [] })
|
|
43
|
+
], HttpLogModule);
|
|
44
|
+
//# sourceMappingURL=http-log.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-log.module.js","sourceRoot":"","sources":["../../../../packages/http-log/src/http-log.module.ts"],"names":[],"mappings":";;;;;AAAA,2CAKwB;AACxB,+DAK+B;AAC/B,uEAGmC;AAG5B,IAAM,aAAa,qBAAnB,MAAM,aAAa;IACxB,MAAM,CAAC,QAAQ,CACb,OAA6B,EAC7B,QAAkB;QAElB,OAAO;YACL,MAAM,EAAE,eAAa;YACrB,OAAO,EAAE,EAAE;YACX,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,iDAAuB,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;YACpE,OAAO,EAAE,EAAE;YACX,MAAM,EAAE,QAAQ;SACjB,CAAC;IACJ,CAAC;IACD,MAAM,CAAC,aAAa,CAClB,OAAkC,EAClC,QAAkB;QAElB,OAAO;YACL,MAAM,EAAE,eAAa;YACrB,OAAO,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;YACrC,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,iDAAuB;oBAChC,UAAU,EAAE,OAAO,CAAC,UAAU;oBAC9B,MAAM,EAAE,OAAO,CAAC,MAAM;iBACvB;aACF;YACD,OAAO,EAAE,EAAE;YACX,MAAM,EAAE,QAAQ;SACjB,CAAC;IACJ,CAAC;IAED,SAAS,CAAC,QAA4B;QACpC,QAAQ;aACL,KAAK,CACJ,+CAAyB,EACzB,uCAAiB,EACjB,uDAAiC,EACjC,oDAA8B,CAC/B;aACA,SAAS,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;CACF,CAAA;AA1CY,sCAAa;wBAAb,aAAa;IADzB,IAAA,eAAM,EAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;GACX,aAAa,CA0CzB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ModuleMetadata } from '@nestjs/common';
|
|
2
|
+
import { FactoryProvider } from '@nestjs/common/interfaces/modules/provider.interface';
|
|
3
|
+
export declare const HTTP_LOG_CONFIG_OPTIONS = "HTTP_LOG_CONFIG_OPTIONS";
|
|
4
|
+
export interface HttpLogModuleOptions {
|
|
5
|
+
http: {
|
|
6
|
+
writeIntoFile: boolean;
|
|
7
|
+
writeIntoConsole: boolean;
|
|
8
|
+
maxFiles: number;
|
|
9
|
+
maxSize: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
type HttpLogModuleAsyncOptions = Pick<ModuleMetadata, 'imports'> & Pick<FactoryProvider<HttpLogModuleOptions>, 'useFactory' | 'inject'>;
|
|
13
|
+
export default HttpLogModuleAsyncOptions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-log.module.options.js","sourceRoot":"","sources":["../../../../packages/http-log/src/http-log.module.options.ts"],"names":[],"mappings":";;;AAGa,QAAA,uBAAuB,GAAG,yBAAyB,CAAC"}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './http-log.module';
|
|
2
|
+
export * from './logger.module';
|
|
3
|
+
export * from './decorators/logger.decorator';
|
|
4
|
+
export * from './constants';
|
|
5
|
+
export * from './services/logger.service';
|
|
6
|
+
export * from './repository/entities/logger.entity';
|
|
7
|
+
export * from './dtos/logger.create.dto';
|
package/src/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./http-log.module"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./logger.module"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./decorators/logger.decorator"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./constants"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./services/logger.service"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./repository/entities/logger.entity"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./dtos/logger.create.dto"), exports);
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/http-log/src/index.ts"],"names":[],"mappings":";;;AAAA,4DAAkC;AAClC,0DAAgC;AAChC,wEAA8C;AAC9C,sDAA4B;AAC5B,oEAA0C;AAC1C,8EAAoD;AACpD,mEAAyC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { Reflector } from '@nestjs/core';
|
|
4
|
+
import { LoggerService } from '../services/logger.service';
|
|
5
|
+
export declare class LoggerInterceptor implements NestInterceptor<any> {
|
|
6
|
+
private readonly reflector;
|
|
7
|
+
private readonly loggerService;
|
|
8
|
+
constructor(reflector: Reflector, loggerService: LoggerService);
|
|
9
|
+
intercept(context: ExecutionContext, next: CallHandler): Promise<Observable<Promise<any> | string>>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LoggerInterceptor = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const rxjs_1 = require("rxjs");
|
|
7
|
+
const core_1 = require("@nestjs/core");
|
|
8
|
+
const logger_service_1 = require("../services/logger.service");
|
|
9
|
+
const logger_constant_1 = require("../constants/logger.constant");
|
|
10
|
+
const logger_enum_constant_1 = require("../constants/logger.enum.constant");
|
|
11
|
+
let LoggerInterceptor = class LoggerInterceptor {
|
|
12
|
+
constructor(reflector, loggerService) {
|
|
13
|
+
this.reflector = reflector;
|
|
14
|
+
this.loggerService = loggerService;
|
|
15
|
+
}
|
|
16
|
+
async intercept(context, next) {
|
|
17
|
+
if (context.getType() === 'http') {
|
|
18
|
+
const ctx = context.switchToHttp();
|
|
19
|
+
const { apiKey, method, originalUrl, user, __id, body, params, path } = ctx.getRequest();
|
|
20
|
+
const responseExpress = ctx.getResponse();
|
|
21
|
+
return next.handle().pipe((0, rxjs_1.tap)(async (response) => {
|
|
22
|
+
const responseData = await response;
|
|
23
|
+
const responseStatus = responseExpress.statusCode;
|
|
24
|
+
const statusCode = responseData?.['statusCode'] ?? responseStatus;
|
|
25
|
+
const loggerAction = this.reflector.get(logger_constant_1.LOGGER_ACTION_META_KEY, context.getHandler());
|
|
26
|
+
const loggerOptions = this.reflector.get(logger_constant_1.LOGGER_OPTIONS_META_KEY, context.getHandler());
|
|
27
|
+
await this.loggerService.raw({
|
|
28
|
+
level: loggerOptions?.level ?? logger_enum_constant_1.ENUM_LOGGER_LEVEL.INFO,
|
|
29
|
+
action: loggerAction,
|
|
30
|
+
apiKey: apiKey?.['_id'],
|
|
31
|
+
description: loggerOptions?.description ??
|
|
32
|
+
`Request ${method} called, url ${originalUrl}, and action ${loggerAction}`,
|
|
33
|
+
user: user?.['_id'],
|
|
34
|
+
requestId: __id,
|
|
35
|
+
method: method,
|
|
36
|
+
role: user?.['role'],
|
|
37
|
+
accessFor: user?.['accessFor'],
|
|
38
|
+
params,
|
|
39
|
+
bodies: body,
|
|
40
|
+
path,
|
|
41
|
+
statusCode,
|
|
42
|
+
tags: loggerOptions?.tags ?? [],
|
|
43
|
+
});
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
return next.handle();
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
exports.LoggerInterceptor = LoggerInterceptor;
|
|
50
|
+
exports.LoggerInterceptor = LoggerInterceptor = tslib_1.__decorate([
|
|
51
|
+
(0, common_1.Injectable)(),
|
|
52
|
+
tslib_1.__metadata("design:paramtypes", [core_1.Reflector,
|
|
53
|
+
logger_service_1.LoggerService])
|
|
54
|
+
], LoggerInterceptor);
|
|
55
|
+
//# sourceMappingURL=logger.interceptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.interceptor.js","sourceRoot":"","sources":["../../../../../packages/http-log/src/interceptors/logger.interceptor.ts"],"names":[],"mappings":";;;;AAAA,2CAKwB;AACxB,+BAAuC;AAGvC,uCAAyC;AACzC,+DAA2D;AA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K,CAAC;oBACvB,WAAW,EACT,aAAa,EAAE,WAAW;wBAC1B,WAAW,MAAM,gBAAgB,WAAW,gBAAgB,YAAY,EAAE;oBAC5E,IAAI,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC;oBACnB,SAAS,EAAE,IAAI;oBACf,MAAM,EAAE,MAA6B;oBACrC,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,CAAC;oBACpB,SAAS,EAAE,IAAI,EAAE,CAAC,WAAW,CAAC;oBAC9B,MAAM;oBACN,MAAM,EAAE,IAAI;oBACZ,IAAI;oBACJ,UAAU;oBACV,IAAI,EAAE,aAAa,EAAE,IAAI,IAAI,EAAE;iBAChC,CAAC,CAAC;YACL,CAAC,CAAC,CACH,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC;CACF,CAAA;AAxDY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;6CAGmB,gBAAS;QACL,8BAAa;GAHpC,iBAAiB,CAwD7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.interface.js","sourceRoot":"","sources":["../../../../../packages/http-log/src/interfaces/logger.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { LoggerCreateDto, LoggerCreateRawDto } from '../dtos/logger.create.dto';
|
|
2
|
+
import { LoggerDoc } from '../repository/entities/logger.entity';
|
|
3
|
+
export interface ILoggerService {
|
|
4
|
+
info(data: LoggerCreateDto): Promise<LoggerDoc>;
|
|
5
|
+
debug(data: LoggerCreateDto): Promise<LoggerDoc>;
|
|
6
|
+
warn(data: LoggerCreateDto): Promise<LoggerDoc>;
|
|
7
|
+
fatal(data: LoggerCreateDto): Promise<LoggerDoc>;
|
|
8
|
+
raw(data: LoggerCreateRawDto): Promise<LoggerDoc>;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.service.interface.js","sourceRoot":"","sources":["../../../../../packages/http-log/src/interfaces/logger.service.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LoggerModule = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const logger_service_1 = require("./services/logger.service");
|
|
7
|
+
const logger_repository_module_1 = require("./repository/logger.repository.module");
|
|
8
|
+
let LoggerModule = class LoggerModule {
|
|
9
|
+
};
|
|
10
|
+
exports.LoggerModule = LoggerModule;
|
|
11
|
+
exports.LoggerModule = LoggerModule = tslib_1.__decorate([
|
|
12
|
+
(0, common_1.Global)(),
|
|
13
|
+
(0, common_1.Module)({
|
|
14
|
+
providers: [logger_service_1.LoggerService],
|
|
15
|
+
exports: [logger_service_1.LoggerService],
|
|
16
|
+
imports: [logger_repository_module_1.LoggerRepositoryModule],
|
|
17
|
+
})
|
|
18
|
+
], LoggerModule);
|
|
19
|
+
//# sourceMappingURL=logger.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.module.js","sourceRoot":"","sources":["../../../../packages/http-log/src/logger.module.ts"],"names":[],"mappings":";;;;AAAA,2CAAgD;AAChD,8DAA0D;AAC1D,oFAA+E;AAQxE,IAAM,YAAY,GAAlB,MAAM,YAAY;CAAG,CAAA;AAAf,oCAAY;uBAAZ,YAAY;IANxB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,8BAAa,CAAC;QAC1B,OAAO,EAAE,CAAC,8BAAa,CAAC;QACxB,OAAO,EAAE,CAAC,iDAAsB,CAAC;KAClC,CAAC;GACW,YAAY,CAAG"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ENUM_AUTH_ACCESS_FOR } from '@tc-libs/authentication';
|
|
2
|
+
import { DatabaseMongoEntityAbstract } from '@tc-libs/database';
|
|
3
|
+
import { Document } from 'mongoose';
|
|
4
|
+
export declare class LoggerEntity extends DatabaseMongoEntityAbstract {
|
|
5
|
+
level: string;
|
|
6
|
+
action: string;
|
|
7
|
+
method: string;
|
|
8
|
+
requestId?: string;
|
|
9
|
+
user?: string;
|
|
10
|
+
apiKey?: string;
|
|
11
|
+
role?: string;
|
|
12
|
+
anonymous: boolean;
|
|
13
|
+
accessFor?: ENUM_AUTH_ACCESS_FOR;
|
|
14
|
+
description: string;
|
|
15
|
+
params?: Record<string, any>;
|
|
16
|
+
bodies?: Record<string, any>;
|
|
17
|
+
statusCode?: number;
|
|
18
|
+
path?: string;
|
|
19
|
+
tags: string[];
|
|
20
|
+
}
|
|
21
|
+
export declare const LoggerSchema: import("mongoose").Schema<LoggerEntity, import("mongoose").Model<LoggerEntity, any, any, any, Document<unknown, any, LoggerEntity> & LoggerEntity & Required<{
|
|
22
|
+
_id: import("mongoose").Types.ObjectId;
|
|
23
|
+
}>, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, LoggerEntity, Document<unknown, {}, LoggerEntity> & LoggerEntity & Required<{
|
|
24
|
+
_id: import("mongoose").Types.ObjectId;
|
|
25
|
+
}>>;
|
|
26
|
+
export type LoggerDoc = LoggerEntity & Document;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LoggerSchema = exports.LoggerEntity = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const authentication_1 = require("@tc-libs/authentication");
|
|
6
|
+
const database_1 = require("@tc-libs/database");
|
|
7
|
+
const logger_enum_constant_1 = require("../../constants/logger.enum.constant");
|
|
8
|
+
const request_1 = require("@tc-libs/request");
|
|
9
|
+
const mongoose_1 = require("@nestjs/mongoose");
|
|
10
|
+
let LoggerEntity = class LoggerEntity extends database_1.DatabaseMongoEntityAbstract {
|
|
11
|
+
};
|
|
12
|
+
exports.LoggerEntity = LoggerEntity;
|
|
13
|
+
tslib_1.__decorate([
|
|
14
|
+
(0, mongoose_1.Prop)({
|
|
15
|
+
required: true,
|
|
16
|
+
enum: logger_enum_constant_1.ENUM_LOGGER_LEVEL,
|
|
17
|
+
type: String,
|
|
18
|
+
}),
|
|
19
|
+
tslib_1.__metadata("design:type", String)
|
|
20
|
+
], LoggerEntity.prototype, "level", void 0);
|
|
21
|
+
tslib_1.__decorate([
|
|
22
|
+
(0, mongoose_1.Prop)({
|
|
23
|
+
required: true,
|
|
24
|
+
type: String,
|
|
25
|
+
}),
|
|
26
|
+
tslib_1.__metadata("design:type", String)
|
|
27
|
+
], LoggerEntity.prototype, "action", void 0);
|
|
28
|
+
tslib_1.__decorate([
|
|
29
|
+
(0, mongoose_1.Prop)({
|
|
30
|
+
required: true,
|
|
31
|
+
enum: request_1.ENUM_REQUEST_METHOD,
|
|
32
|
+
type: String,
|
|
33
|
+
}),
|
|
34
|
+
tslib_1.__metadata("design:type", String)
|
|
35
|
+
], LoggerEntity.prototype, "method", void 0);
|
|
36
|
+
tslib_1.__decorate([
|
|
37
|
+
(0, mongoose_1.Prop)({
|
|
38
|
+
required: false,
|
|
39
|
+
type: String,
|
|
40
|
+
}),
|
|
41
|
+
tslib_1.__metadata("design:type", String)
|
|
42
|
+
], LoggerEntity.prototype, "requestId", void 0);
|
|
43
|
+
tslib_1.__decorate([
|
|
44
|
+
(0, mongoose_1.Prop)({
|
|
45
|
+
required: false,
|
|
46
|
+
type: String,
|
|
47
|
+
}),
|
|
48
|
+
tslib_1.__metadata("design:type", String)
|
|
49
|
+
], LoggerEntity.prototype, "user", void 0);
|
|
50
|
+
tslib_1.__decorate([
|
|
51
|
+
(0, mongoose_1.Prop)({
|
|
52
|
+
required: false,
|
|
53
|
+
type: String,
|
|
54
|
+
}),
|
|
55
|
+
tslib_1.__metadata("design:type", String)
|
|
56
|
+
], LoggerEntity.prototype, "apiKey", void 0);
|
|
57
|
+
tslib_1.__decorate([
|
|
58
|
+
(0, mongoose_1.Prop)({
|
|
59
|
+
required: false,
|
|
60
|
+
type: String,
|
|
61
|
+
}),
|
|
62
|
+
tslib_1.__metadata("design:type", String)
|
|
63
|
+
], LoggerEntity.prototype, "role", void 0);
|
|
64
|
+
tslib_1.__decorate([
|
|
65
|
+
(0, mongoose_1.Prop)({
|
|
66
|
+
required: true,
|
|
67
|
+
default: true,
|
|
68
|
+
type: Boolean,
|
|
69
|
+
}),
|
|
70
|
+
tslib_1.__metadata("design:type", Boolean)
|
|
71
|
+
], LoggerEntity.prototype, "anonymous", void 0);
|
|
72
|
+
tslib_1.__decorate([
|
|
73
|
+
(0, mongoose_1.Prop)({
|
|
74
|
+
required: false,
|
|
75
|
+
enum: authentication_1.ENUM_AUTH_ACCESS_FOR,
|
|
76
|
+
type: String,
|
|
77
|
+
}),
|
|
78
|
+
tslib_1.__metadata("design:type", String)
|
|
79
|
+
], LoggerEntity.prototype, "accessFor", void 0);
|
|
80
|
+
tslib_1.__decorate([
|
|
81
|
+
(0, mongoose_1.Prop)({
|
|
82
|
+
required: true,
|
|
83
|
+
type: String,
|
|
84
|
+
}),
|
|
85
|
+
tslib_1.__metadata("design:type", String)
|
|
86
|
+
], LoggerEntity.prototype, "description", void 0);
|
|
87
|
+
tslib_1.__decorate([
|
|
88
|
+
(0, mongoose_1.Prop)({
|
|
89
|
+
required: false,
|
|
90
|
+
type: Object,
|
|
91
|
+
}),
|
|
92
|
+
tslib_1.__metadata("design:type", Object)
|
|
93
|
+
], LoggerEntity.prototype, "params", void 0);
|
|
94
|
+
tslib_1.__decorate([
|
|
95
|
+
(0, mongoose_1.Prop)({
|
|
96
|
+
required: false,
|
|
97
|
+
type: Object,
|
|
98
|
+
}),
|
|
99
|
+
tslib_1.__metadata("design:type", Object)
|
|
100
|
+
], LoggerEntity.prototype, "bodies", void 0);
|
|
101
|
+
tslib_1.__decorate([
|
|
102
|
+
(0, mongoose_1.Prop)({
|
|
103
|
+
required: false,
|
|
104
|
+
type: Number,
|
|
105
|
+
}),
|
|
106
|
+
tslib_1.__metadata("design:type", Number)
|
|
107
|
+
], LoggerEntity.prototype, "statusCode", void 0);
|
|
108
|
+
tslib_1.__decorate([
|
|
109
|
+
(0, mongoose_1.Prop)({
|
|
110
|
+
required: false,
|
|
111
|
+
type: String,
|
|
112
|
+
}),
|
|
113
|
+
tslib_1.__metadata("design:type", String)
|
|
114
|
+
], LoggerEntity.prototype, "path", void 0);
|
|
115
|
+
tslib_1.__decorate([
|
|
116
|
+
(0, mongoose_1.Prop)({
|
|
117
|
+
required: false,
|
|
118
|
+
default: [],
|
|
119
|
+
type: (Array),
|
|
120
|
+
}),
|
|
121
|
+
tslib_1.__metadata("design:type", Array)
|
|
122
|
+
], LoggerEntity.prototype, "tags", void 0);
|
|
123
|
+
exports.LoggerEntity = LoggerEntity = tslib_1.__decorate([
|
|
124
|
+
(0, database_1.DatabaseEntity)({ collection: 'loggers' })
|
|
125
|
+
], LoggerEntity);
|
|
126
|
+
exports.LoggerSchema = mongoose_1.SchemaFactory.createForClass(LoggerEntity);
|
|
127
|
+
//# sourceMappingURL=logger.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.entity.js","sourceRoot":"","sources":["../../../../../../packages/http-log/src/repository/entities/logger.entity.ts"],"names":[],"mappings":";;;;AAAA,4DAA+D;AAC/D,gDAAgF;AAChF,+EAAyE;AACzE,8CAAuD;AACvD,+CAAuD;AAIhD,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,sCAA2B;CA+F5D,CAAA;AA/FY,oCAAY;AAMvB;IALC,IAAA,eAAI,EAAC;QACJ,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE,wCAAiB;QACvB,IAAI,EAAE,MAAM;KACb,CAAC;;2CACY;AAMd;IAJC,IAAA,eAAI,EAAC;QACJ,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE,MAAM;KACb,CAAC;;4CACa;AAOf;IAL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C;;0CACY;AAOd;IALC,IAAA,eAAI,EAAC;QACJ,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,EAAE;QACX,IAAI,EAAE,CAAA,KAAa,CAAA;KACpB,CAAC;;0CACa;uBA9FJ,YAAY;IADxB,IAAA,yBAAc,EAAC,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;GAC7B,YAAY,CA+FxB;AAEY,QAAA,YAAY,GAAG,wBAAa,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LoggerRepositoryModule = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const mongoose_1 = require("@nestjs/mongoose");
|
|
7
|
+
const logger_entity_1 = require("./entities/logger.entity");
|
|
8
|
+
const logger_repository_1 = require("./repositories/logger.repository");
|
|
9
|
+
let LoggerRepositoryModule = class LoggerRepositoryModule {
|
|
10
|
+
};
|
|
11
|
+
exports.LoggerRepositoryModule = LoggerRepositoryModule;
|
|
12
|
+
exports.LoggerRepositoryModule = LoggerRepositoryModule = tslib_1.__decorate([
|
|
13
|
+
(0, common_1.Module)({
|
|
14
|
+
providers: [logger_repository_1.LoggerRepository],
|
|
15
|
+
exports: [logger_repository_1.LoggerRepository],
|
|
16
|
+
controllers: [],
|
|
17
|
+
imports: [
|
|
18
|
+
mongoose_1.MongooseModule.forFeature([
|
|
19
|
+
{
|
|
20
|
+
name: logger_entity_1.LoggerEntity.name,
|
|
21
|
+
schema: logger_entity_1.LoggerSchema,
|
|
22
|
+
},
|
|
23
|
+
]),
|
|
24
|
+
],
|
|
25
|
+
})
|
|
26
|
+
], LoggerRepositoryModule);
|
|
27
|
+
//# sourceMappingURL=logger.repository.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.repository.module.js","sourceRoot":"","sources":["../../../../../packages/http-log/src/repository/logger.repository.module.ts"],"names":[],"mappings":";;;;AAAA,2CAAwC;AACxC,+CAAkD;AAClD,4DAAsE;AACtE,wEAAoE;AAe7D,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;CAAG,CAAA;AAAzB,wDAAsB;iCAAtB,sBAAsB;IAblC,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,oCAAgB,CAAC;QAC7B,OAAO,EAAE,CAAC,oCAAgB,CAAC;QAC3B,WAAW,EAAE,EAAE;QACf,OAAO,EAAE;YACP,yBAAc,CAAC,UAAU,CAAC;gBACxB;oBACE,IAAI,EAAE,4BAAY,CAAC,IAAI;oBACvB,MAAM,EAAE,4BAAY;iBACrB;aACF,CAAC;SACH;KACF,CAAC;GACW,sBAAsB,CAAG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Logger } from '@nestjs/common';
|
|
2
|
+
import { DatabaseMongoRepositoryAbstract } from '@tc-libs/database';
|
|
3
|
+
import { Connection, Model } from 'mongoose';
|
|
4
|
+
import { LoggerDoc, LoggerEntity } from '../entities/logger.entity';
|
|
5
|
+
import { AppCacheService } from '@tc-libs/app-cache';
|
|
6
|
+
export declare class LoggerRepository extends DatabaseMongoRepositoryAbstract<LoggerEntity, LoggerDoc> {
|
|
7
|
+
protected readonly LoggerDoc: Model<LoggerEntity>;
|
|
8
|
+
protected readonly connection: Connection;
|
|
9
|
+
protected readonly _logger: Logger;
|
|
10
|
+
constructor(LoggerDoc: Model<LoggerEntity>, connection: Connection, _cache: AppCacheService);
|
|
11
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var LoggerRepository_1;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.LoggerRepository = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const common_1 = require("@nestjs/common");
|
|
7
|
+
const database_1 = require("@tc-libs/database");
|
|
8
|
+
const mongoose_1 = require("mongoose");
|
|
9
|
+
const logger_entity_1 = require("../entities/logger.entity");
|
|
10
|
+
const app_cache_1 = require("@tc-libs/app-cache");
|
|
11
|
+
let LoggerRepository = LoggerRepository_1 = class LoggerRepository extends database_1.DatabaseMongoRepositoryAbstract {
|
|
12
|
+
constructor(LoggerDoc, connection, _cache) {
|
|
13
|
+
super(LoggerDoc, connection, _cache);
|
|
14
|
+
this.LoggerDoc = LoggerDoc;
|
|
15
|
+
this.connection = connection;
|
|
16
|
+
this._logger = new common_1.Logger(LoggerRepository_1.name);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
exports.LoggerRepository = LoggerRepository;
|
|
20
|
+
exports.LoggerRepository = LoggerRepository = LoggerRepository_1 = tslib_1.__decorate([
|
|
21
|
+
(0, common_1.Injectable)(),
|
|
22
|
+
tslib_1.__param(0, (0, database_1.DatabaseModel)(logger_entity_1.LoggerEntity.name)),
|
|
23
|
+
tslib_1.__param(1, (0, database_1.DatabaseConnection)()),
|
|
24
|
+
tslib_1.__metadata("design:paramtypes", [mongoose_1.Model,
|
|
25
|
+
mongoose_1.Connection,
|
|
26
|
+
app_cache_1.AppCacheService])
|
|
27
|
+
], LoggerRepository);
|
|
28
|
+
//# sourceMappingURL=logger.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.repository.js","sourceRoot":"","sources":["../../../../../../packages/http-log/src/repository/repositories/logger.repository.ts"],"names":[],"mappings":";;;;;AAAA,2CAAoD;AACpD,gDAI2B;AAC3B,uCAA6C;AAC7C,6DAAoE;AAEpE,kDAAqD;AAG9C,IAAM,gBAAgB,wBAAtB,MAAM,gBAAiB,SAAQ,0CAGrC;IAEC,YAEE,SAAiD,EAEjD,UAAyC,EACzC,MAAuB;QAEvB,KAAK,CAAC,SAAS,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;QALlB,cAAS,GAAT,SAAS,CAAqB;QAE9B,eAAU,GAAV,UAAU,CAAY;QALxB,YAAO,GAAW,IAAI,eAAM,CAAC,kBAAgB,CAAC,IAAI,CAAC,CAAC;IASvE,CAAC;CACF,CAAA;AAdY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;IAOR,mBAAA,IAAA,wBAAa,EAAC,4BAAY,CAAC,IAAI,CAAC,CAAA;IAEhC,mBAAA,IAAA,6BAAkB,GAAE,CAAA;6CADS,gBAAK;QAEJ,qBAAU;QACjC,2BAAe;GAVd,gBAAgB,CAc5B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { LoggerCreateDto, LoggerCreateRawDto } from '../dtos/logger.create.dto';
|
|
2
|
+
import { ILoggerService } from '../interfaces/logger.service.interface';
|
|
3
|
+
import { LoggerDoc } from '../repository/entities/logger.entity';
|
|
4
|
+
import { LoggerRepository } from '../repository/repositories/logger.repository';
|
|
5
|
+
export declare class LoggerService implements ILoggerService {
|
|
6
|
+
private readonly loggerRepository;
|
|
7
|
+
constructor(loggerRepository: LoggerRepository);
|
|
8
|
+
info({ action, description, user, method, requestId, role, accessFor, params, bodies, path, statusCode, tags, }: LoggerCreateDto): Promise<LoggerDoc>;
|
|
9
|
+
debug({ action, description, user, method, requestId, role, accessFor, params, bodies, path, statusCode, tags, }: LoggerCreateDto): Promise<LoggerDoc>;
|
|
10
|
+
warn({ action, description, user, method, requestId, role, accessFor, params, bodies, path, statusCode, tags, }: LoggerCreateDto): Promise<LoggerDoc>;
|
|
11
|
+
fatal({ action, description, user, method, requestId, role, accessFor, params, bodies, path, statusCode, tags, }: LoggerCreateDto): Promise<LoggerDoc>;
|
|
12
|
+
raw({ level, action, description, user, method, requestId, role, accessFor, params, bodies, path, statusCode, tags, apiKey, }: LoggerCreateRawDto): Promise<LoggerDoc>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LoggerService = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const logger_enum_constant_1 = require("../constants/logger.enum.constant");
|
|
7
|
+
const logger_entity_1 = require("../repository/entities/logger.entity");
|
|
8
|
+
const logger_repository_1 = require("../repository/repositories/logger.repository");
|
|
9
|
+
let LoggerService = class LoggerService {
|
|
10
|
+
constructor(loggerRepository) {
|
|
11
|
+
this.loggerRepository = loggerRepository;
|
|
12
|
+
}
|
|
13
|
+
async info({ action, description, user, method, requestId, role, accessFor, params, bodies, path, statusCode, tags, }) {
|
|
14
|
+
const create = new logger_entity_1.LoggerEntity();
|
|
15
|
+
create.level = logger_enum_constant_1.ENUM_LOGGER_LEVEL.INFO;
|
|
16
|
+
create.user = user;
|
|
17
|
+
create.anonymous = !user;
|
|
18
|
+
create.action = action;
|
|
19
|
+
create.description = description;
|
|
20
|
+
create.method = method;
|
|
21
|
+
create.requestId = requestId;
|
|
22
|
+
create.role = role;
|
|
23
|
+
create.accessFor = accessFor;
|
|
24
|
+
create.params = params;
|
|
25
|
+
create.bodies = bodies;
|
|
26
|
+
create.path = path;
|
|
27
|
+
create.statusCode = statusCode;
|
|
28
|
+
create.tags = tags ?? [];
|
|
29
|
+
return this.loggerRepository.create(create);
|
|
30
|
+
}
|
|
31
|
+
async debug({ action, description, user, method, requestId, role, accessFor, params, bodies, path, statusCode, tags, }) {
|
|
32
|
+
const create = new logger_entity_1.LoggerEntity();
|
|
33
|
+
create.level = logger_enum_constant_1.ENUM_LOGGER_LEVEL.DEBUG;
|
|
34
|
+
create.user = user;
|
|
35
|
+
create.anonymous = !user;
|
|
36
|
+
create.action = action;
|
|
37
|
+
create.description = description;
|
|
38
|
+
create.method = method;
|
|
39
|
+
create.requestId = requestId;
|
|
40
|
+
create.role = role;
|
|
41
|
+
create.accessFor = accessFor;
|
|
42
|
+
create.params = params;
|
|
43
|
+
create.bodies = bodies;
|
|
44
|
+
create.path = path;
|
|
45
|
+
create.statusCode = statusCode;
|
|
46
|
+
create.tags = tags ?? [];
|
|
47
|
+
return this.loggerRepository.create(create);
|
|
48
|
+
}
|
|
49
|
+
async warn({ action, description, user, method, requestId, role, accessFor, params, bodies, path, statusCode, tags, }) {
|
|
50
|
+
const create = new logger_entity_1.LoggerEntity();
|
|
51
|
+
create.level = logger_enum_constant_1.ENUM_LOGGER_LEVEL.WARM;
|
|
52
|
+
create.user = user;
|
|
53
|
+
create.anonymous = !user;
|
|
54
|
+
create.action = action;
|
|
55
|
+
create.description = description;
|
|
56
|
+
create.method = method;
|
|
57
|
+
create.requestId = requestId;
|
|
58
|
+
create.role = role;
|
|
59
|
+
create.accessFor = accessFor;
|
|
60
|
+
create.params = params;
|
|
61
|
+
create.bodies = bodies;
|
|
62
|
+
create.path = path;
|
|
63
|
+
create.statusCode = statusCode;
|
|
64
|
+
create.tags = tags ?? [];
|
|
65
|
+
return this.loggerRepository.create(create);
|
|
66
|
+
}
|
|
67
|
+
async fatal({ action, description, user, method, requestId, role, accessFor, params, bodies, path, statusCode, tags, }) {
|
|
68
|
+
const create = new logger_entity_1.LoggerEntity();
|
|
69
|
+
create.level = logger_enum_constant_1.ENUM_LOGGER_LEVEL.FATAL;
|
|
70
|
+
create.user = user;
|
|
71
|
+
create.anonymous = !user;
|
|
72
|
+
create.action = action;
|
|
73
|
+
create.description = description;
|
|
74
|
+
create.method = method;
|
|
75
|
+
create.requestId = requestId;
|
|
76
|
+
create.role = role;
|
|
77
|
+
create.accessFor = accessFor;
|
|
78
|
+
create.params = params;
|
|
79
|
+
create.bodies = bodies;
|
|
80
|
+
create.path = path;
|
|
81
|
+
create.statusCode = statusCode;
|
|
82
|
+
create.tags = tags ?? [];
|
|
83
|
+
return this.loggerRepository.create(create);
|
|
84
|
+
}
|
|
85
|
+
async raw({ level, action, description, user, method, requestId, role, accessFor, params, bodies, path, statusCode, tags, apiKey, }) {
|
|
86
|
+
const create = new logger_entity_1.LoggerEntity();
|
|
87
|
+
create.level = level;
|
|
88
|
+
create.user = user;
|
|
89
|
+
create.anonymous = !user;
|
|
90
|
+
create.action = action;
|
|
91
|
+
create.description = description;
|
|
92
|
+
create.method = method;
|
|
93
|
+
create.requestId = requestId;
|
|
94
|
+
create.role = role;
|
|
95
|
+
create.accessFor = accessFor;
|
|
96
|
+
create.params = params;
|
|
97
|
+
create.bodies = bodies;
|
|
98
|
+
create.path = path;
|
|
99
|
+
create.statusCode = statusCode;
|
|
100
|
+
create.apiKey = apiKey;
|
|
101
|
+
create.tags = tags ?? [];
|
|
102
|
+
return this.loggerRepository.create(create);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
exports.LoggerService = LoggerService;
|
|
106
|
+
exports.LoggerService = LoggerService = tslib_1.__decorate([
|
|
107
|
+
(0, common_1.Injectable)(),
|
|
108
|
+
tslib_1.__metadata("design:paramtypes", [logger_repository_1.LoggerRepository])
|
|
109
|
+
], LoggerService);
|
|
110
|
+
//# sourceMappingURL=logger.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.service.js","sourceRoot":"","sources":["../../../../../packages/http-log/src/services/logger.service.ts"],"names":[],"mappings":";;;;AAAA,2CAA4C;AAC5C,4EAAsE;AAGtE,wEAA+E;AAC/E,oFAAgF;AAGzE,IAAM,aAAa,GAAnB,MAAM,aAAa;IACxB,YAA6B,gBAAkC;QAAlC,qBAAgB,GAAhB,gBAAgB,CAAkB;IAAG,CAAC;IAEnE,KAAK,CAAC,IAAI,CAAC,EACT,MAAM,EACN,WAAW,EACX,IAAI,EACJ,MAAM,EACN,SAAS,EACT,IAAI,EACJ,SAAS,EACT,MAAM,EACN,MAAM,EACN,IAAI,EACJ,UAAU,EACV,IAAI,GACY;QAChB,MAAM,MAAM,GAAiB,IAAI,4BAAY,EAAE,CAAC;QAChD,MAAM,CAAC,KAAK,GAAG,wCAAiB,CAAC,IAAI,CAAC;QACtC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;QACnB,MAAM,CAA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