loglyn 0.0.1
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 +163 -0
- package/client/dist/assets/index-4cmYap6R.js +1 -0
- package/client/dist/assets/index-B2J1zNAH.css +2 -0
- package/client/dist/favicon.ico +0 -0
- package/client/dist/icon.png +0 -0
- package/client/dist/index.html +18 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/nest-logs/index.d.ts +3 -0
- package/dist/nest-logs/index.js +8 -0
- package/dist/nest-logs/index.js.map +1 -0
- package/dist/nest-logs/nest-logs.controller.d.ts +39 -0
- package/dist/nest-logs/nest-logs.controller.js +307 -0
- package/dist/nest-logs/nest-logs.controller.js.map +1 -0
- package/dist/nest-logs/nest-logs.interfaces.d.ts +44 -0
- package/dist/nest-logs/nest-logs.interfaces.js +3 -0
- package/dist/nest-logs/nest-logs.interfaces.js.map +1 -0
- package/dist/nest-logs/nest-logs.logger.d.ts +27 -0
- package/dist/nest-logs/nest-logs.logger.js +162 -0
- package/dist/nest-logs/nest-logs.logger.js.map +1 -0
- package/dist/nest-logs/nest-logs.middleware.d.ts +15 -0
- package/dist/nest-logs/nest-logs.middleware.js +121 -0
- package/dist/nest-logs/nest-logs.middleware.js.map +1 -0
- package/dist/nest-logs/nest-logs.module.d.ts +6 -0
- package/dist/nest-logs/nest-logs.module.js +38 -0
- package/dist/nest-logs/nest-logs.module.js.map +1 -0
- package/package.json +97 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { LoggerService } from '@nestjs/common';
|
|
2
|
+
import type { Response } from 'express';
|
|
3
|
+
import type { NestLogsOptions, LogEntry } from './nest-logs.interfaces';
|
|
4
|
+
export declare const NEST_LOGS_OPTIONS = "NEST_LOGS_OPTIONS";
|
|
5
|
+
export declare class NestLogsLogger implements LoggerService {
|
|
6
|
+
private readonly options;
|
|
7
|
+
private readonly buffer;
|
|
8
|
+
private readonly clients;
|
|
9
|
+
private idCounter;
|
|
10
|
+
constructor(options: NestLogsOptions);
|
|
11
|
+
private currentDate;
|
|
12
|
+
private stringify;
|
|
13
|
+
private createEntry;
|
|
14
|
+
private push;
|
|
15
|
+
private writeToFile;
|
|
16
|
+
private cleanupOldFiles;
|
|
17
|
+
private loadTodayFile;
|
|
18
|
+
private broadcast;
|
|
19
|
+
addSseClient(res: Response): void;
|
|
20
|
+
getBuffer(): LogEntry[];
|
|
21
|
+
request(entry: LogEntry): void;
|
|
22
|
+
log(message: unknown, context?: string): void;
|
|
23
|
+
error(message: unknown, trace?: string, context?: string): void;
|
|
24
|
+
warn(message: unknown, context?: string): void;
|
|
25
|
+
debug(message: unknown, context?: string): void;
|
|
26
|
+
verbose(message: unknown, context?: string): void;
|
|
27
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.NestLogsLogger = exports.NEST_LOGS_OPTIONS = void 0;
|
|
19
|
+
const common_1 = require("@nestjs/common");
|
|
20
|
+
const fs_1 = require("fs");
|
|
21
|
+
const path_1 = require("path");
|
|
22
|
+
const moment_timezone_1 = __importDefault(require("moment-timezone"));
|
|
23
|
+
const lodash_1 = require("lodash");
|
|
24
|
+
exports.NEST_LOGS_OPTIONS = 'NEST_LOGS_OPTIONS';
|
|
25
|
+
let NestLogsLogger = class NestLogsLogger {
|
|
26
|
+
options;
|
|
27
|
+
buffer = [];
|
|
28
|
+
clients = new Set();
|
|
29
|
+
idCounter = 0;
|
|
30
|
+
constructor(options) {
|
|
31
|
+
this.options = options;
|
|
32
|
+
if (!moment_timezone_1.default.tz.zone(options.timezone)) {
|
|
33
|
+
throw new Error(`Invalid nest-logs timezone: ${options.timezone}`);
|
|
34
|
+
}
|
|
35
|
+
if (options.storagePath) {
|
|
36
|
+
(0, fs_1.mkdirSync)(options.storagePath, { recursive: true });
|
|
37
|
+
this.loadTodayFile();
|
|
38
|
+
this.cleanupOldFiles();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
currentDate() {
|
|
42
|
+
return (0, moment_timezone_1.default)().tz(this.options.timezone).format('YYYY-MM-DD');
|
|
43
|
+
}
|
|
44
|
+
stringify(message) {
|
|
45
|
+
if (typeof message === 'string')
|
|
46
|
+
return message;
|
|
47
|
+
try {
|
|
48
|
+
const seen = new WeakSet();
|
|
49
|
+
return JSON.stringify(message, (_, value) => {
|
|
50
|
+
if (typeof value !== 'object' || value === null)
|
|
51
|
+
return value;
|
|
52
|
+
if (seen.has(value))
|
|
53
|
+
return '[Circular]';
|
|
54
|
+
seen.add(value);
|
|
55
|
+
return value;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return String(message);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
createEntry(level, message, context, trace) {
|
|
63
|
+
return {
|
|
64
|
+
type: 'log',
|
|
65
|
+
id: `${Date.now()}-${++this.idCounter}`,
|
|
66
|
+
timestamp: new Date().toISOString(),
|
|
67
|
+
level,
|
|
68
|
+
context: context ?? 'App',
|
|
69
|
+
message: this.stringify(message),
|
|
70
|
+
trace,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
push(entry) {
|
|
74
|
+
const max = this.options.maxLogs ?? 1000;
|
|
75
|
+
this.buffer.push(entry);
|
|
76
|
+
const next = (0, lodash_1.takeRight)((0, lodash_1.uniqBy)(this.buffer, 'id'), max);
|
|
77
|
+
this.buffer.splice(0, this.buffer.length, ...next);
|
|
78
|
+
if (this.options.storagePath) {
|
|
79
|
+
this.writeToFile(entry);
|
|
80
|
+
}
|
|
81
|
+
this.broadcast(entry);
|
|
82
|
+
}
|
|
83
|
+
writeToFile(entry) {
|
|
84
|
+
const date = this.currentDate();
|
|
85
|
+
const file = (0, path_1.join)(this.options.storagePath, `${date}.jsonl`);
|
|
86
|
+
(0, fs_1.writeFileSync)(file, JSON.stringify(entry) + '\n', { flag: 'a' });
|
|
87
|
+
}
|
|
88
|
+
cleanupOldFiles() {
|
|
89
|
+
if (this.options.retentionDays === undefined)
|
|
90
|
+
return;
|
|
91
|
+
const retention = this.options.retentionDays;
|
|
92
|
+
const dir = this.options.storagePath;
|
|
93
|
+
const cutoff = (0, moment_timezone_1.default)().tz(this.options.timezone).subtract(retention, 'days');
|
|
94
|
+
(0, fs_1.readdirSync)(dir)
|
|
95
|
+
.filter((f) => f.endsWith('.jsonl'))
|
|
96
|
+
.forEach((f) => {
|
|
97
|
+
const fileDate = moment_timezone_1.default.tz(f.replace('.jsonl', ''), 'YYYY-MM-DD', this.options.timezone);
|
|
98
|
+
if (fileDate.isBefore(cutoff, 'day'))
|
|
99
|
+
(0, fs_1.unlinkSync)((0, path_1.join)(dir, f));
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
loadTodayFile() {
|
|
103
|
+
const file = (0, path_1.join)(this.options.storagePath, `${this.currentDate()}.jsonl`);
|
|
104
|
+
if (!(0, fs_1.existsSync)(file))
|
|
105
|
+
return;
|
|
106
|
+
const max = this.options.maxLogs ?? 1000;
|
|
107
|
+
const entries = (0, fs_1.readFileSync)(file, 'utf8')
|
|
108
|
+
.split('\n')
|
|
109
|
+
.filter(Boolean)
|
|
110
|
+
.map((line) => JSON.parse(line));
|
|
111
|
+
this.buffer.push(...(0, lodash_1.takeRight)((0, lodash_1.uniqBy)(entries, 'id'), max));
|
|
112
|
+
}
|
|
113
|
+
broadcast(entry) {
|
|
114
|
+
const data = `event: log\ndata: ${JSON.stringify(entry)}\n\n`;
|
|
115
|
+
this.clients.forEach((res) => {
|
|
116
|
+
try {
|
|
117
|
+
res.write(data);
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
this.clients.delete(res);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
addSseClient(res) {
|
|
125
|
+
this.clients.add(res);
|
|
126
|
+
res.write(`event: history\ndata: ${JSON.stringify(this.buffer)}\n\n`);
|
|
127
|
+
res.on('close', () => this.clients.delete(res));
|
|
128
|
+
}
|
|
129
|
+
getBuffer() {
|
|
130
|
+
return this.buffer;
|
|
131
|
+
}
|
|
132
|
+
request(entry) {
|
|
133
|
+
this.push(entry);
|
|
134
|
+
}
|
|
135
|
+
log(message, context) {
|
|
136
|
+
process.stdout.write(`[LOG] ${context ?? ''} ${message}\n`);
|
|
137
|
+
this.push(this.createEntry('log', message, context));
|
|
138
|
+
}
|
|
139
|
+
error(message, trace, context) {
|
|
140
|
+
process.stderr.write(`[ERR] ${context ?? ''} ${message}${trace ? '\n' + trace : ''}\n`);
|
|
141
|
+
this.push(this.createEntry('error', message, context, trace));
|
|
142
|
+
}
|
|
143
|
+
warn(message, context) {
|
|
144
|
+
process.stdout.write(`[WARN] ${context ?? ''} ${message}\n`);
|
|
145
|
+
this.push(this.createEntry('warn', message, context));
|
|
146
|
+
}
|
|
147
|
+
debug(message, context) {
|
|
148
|
+
process.stdout.write(`[DEBUG] ${context ?? ''} ${message}\n`);
|
|
149
|
+
this.push(this.createEntry('debug', message, context));
|
|
150
|
+
}
|
|
151
|
+
verbose(message, context) {
|
|
152
|
+
process.stdout.write(`[VERBOSE] ${context ?? ''} ${message}\n`);
|
|
153
|
+
this.push(this.createEntry('verbose', message, context));
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
exports.NestLogsLogger = NestLogsLogger;
|
|
157
|
+
exports.NestLogsLogger = NestLogsLogger = __decorate([
|
|
158
|
+
(0, common_1.Injectable)(),
|
|
159
|
+
__param(0, (0, common_1.Inject)(exports.NEST_LOGS_OPTIONS)),
|
|
160
|
+
__metadata("design:paramtypes", [Object])
|
|
161
|
+
], NestLogsLogger);
|
|
162
|
+
//# sourceMappingURL=nest-logs.logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nest-logs.logger.js","sourceRoot":"","sources":["../../src/nest-logs/nest-logs.logger.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,2CAAmE;AACnE,2BAAiG;AACjG,+BAA4B;AAE5B,sEAAqC;AACrC,mCAA2C;AAG9B,QAAA,iBAAiB,GAAG,mBAAmB,CAAC;AAG9C,IAAM,cAAc,GAApB,MAAM,cAAc;IAK+B;IAJvC,MAAM,GAAe,EAAE,CAAC;IACxB,OAAO,GAAkB,IAAI,GAAG,EAAE,CAAC;IAC5C,SAAS,GAAG,CAAC,CAAC;IAEtB,YAAwD,OAAwB;QAAxB,YAAO,GAAP,OAAO,CAAiB;QAC9E,IAAI,CAAC,yBAAM,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CAAC,+BAA+B,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;QACrE,CAAC;QAED,IAAI,OAAO,CAAC,WAA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sLogger } from './nest-logs.logger';
|
|
4
|
+
import type { NestLogsOptions } from './nest-logs.interfaces';
|
|
5
|
+
export declare class NestLogsMiddleware implements NestMiddleware {
|
|
6
|
+
private readonly logger;
|
|
7
|
+
private readonly options;
|
|
8
|
+
constructor(logger: NestLogsLogger, options: NestLogsOptions);
|
|
9
|
+
use(req: Request, res: Response, next: NextFunction): void;
|
|
10
|
+
private shouldSkip;
|
|
11
|
+
private createEntry;
|
|
12
|
+
private sanitize;
|
|
13
|
+
private redact;
|
|
14
|
+
private truncate;
|
|
15
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.NestLogsMiddleware = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const nest_logs_logger_1 = require("./nest-logs.logger");
|
|
18
|
+
const DEFAULT_REDACT_KEYS = [
|
|
19
|
+
'authorization',
|
|
20
|
+
'cookie',
|
|
21
|
+
'set-cookie',
|
|
22
|
+
'password',
|
|
23
|
+
'token',
|
|
24
|
+
'secret',
|
|
25
|
+
'api-key',
|
|
26
|
+
'x-api-key',
|
|
27
|
+
];
|
|
28
|
+
let NestLogsMiddleware = class NestLogsMiddleware {
|
|
29
|
+
logger;
|
|
30
|
+
options;
|
|
31
|
+
constructor(logger, options) {
|
|
32
|
+
this.logger = logger;
|
|
33
|
+
this.options = options;
|
|
34
|
+
}
|
|
35
|
+
use(req, res, next) {
|
|
36
|
+
if (!this.options.captureRequests || this.shouldSkip(req))
|
|
37
|
+
return next();
|
|
38
|
+
const startedAt = Date.now();
|
|
39
|
+
let finished = false;
|
|
40
|
+
let responseBody;
|
|
41
|
+
if (this.options.captureResponseBody) {
|
|
42
|
+
const send = res.send.bind(res);
|
|
43
|
+
const json = res.json.bind(res);
|
|
44
|
+
res.send = ((body) => {
|
|
45
|
+
responseBody = body;
|
|
46
|
+
return send(body);
|
|
47
|
+
});
|
|
48
|
+
res.json = ((body) => {
|
|
49
|
+
responseBody = body;
|
|
50
|
+
return json(body);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
res.on('finish', () => {
|
|
54
|
+
finished = true;
|
|
55
|
+
this.logger.request(this.createEntry(req, res, startedAt, undefined, responseBody));
|
|
56
|
+
});
|
|
57
|
+
res.on('close', () => {
|
|
58
|
+
if (finished)
|
|
59
|
+
return;
|
|
60
|
+
this.logger.request(this.createEntry(req, res, startedAt, 'aborted', responseBody));
|
|
61
|
+
});
|
|
62
|
+
next();
|
|
63
|
+
}
|
|
64
|
+
shouldSkip(req) {
|
|
65
|
+
const path = `/${(this.options.path ?? '/nest-logs').replace(/^\/|\/$/g, '')}`;
|
|
66
|
+
const requestPath = `/${req.path.replace(/^\/|\/$/g, '')}`;
|
|
67
|
+
return requestPath === path || requestPath.startsWith(`${path}/`);
|
|
68
|
+
}
|
|
69
|
+
createEntry(req, res, startedAt, error, responseBody) {
|
|
70
|
+
const statusCode = res.statusCode;
|
|
71
|
+
return {
|
|
72
|
+
type: 'request',
|
|
73
|
+
id: `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
|
74
|
+
timestamp: new Date().toISOString(),
|
|
75
|
+
level: statusCode >= 500 || error ? 'error' : statusCode >= 400 ? 'warn' : 'log',
|
|
76
|
+
method: req.method,
|
|
77
|
+
path: req.originalUrl || req.url,
|
|
78
|
+
statusCode,
|
|
79
|
+
durationMs: Date.now() - startedAt,
|
|
80
|
+
ip: req.ip,
|
|
81
|
+
userAgent: req.get('user-agent'),
|
|
82
|
+
requestHeaders: this.sanitize(req.headers),
|
|
83
|
+
responseHeaders: this.sanitize(res.getHeaders()),
|
|
84
|
+
query: this.sanitize(req.query),
|
|
85
|
+
body: this.options.captureRequestBody ? this.sanitize(req.body) : undefined,
|
|
86
|
+
responseBody: this.options.captureResponseBody ? this.sanitize(responseBody) : undefined,
|
|
87
|
+
error,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
sanitize(value) {
|
|
91
|
+
return this.truncate(this.redact(value));
|
|
92
|
+
}
|
|
93
|
+
redact(value, seen = new WeakSet()) {
|
|
94
|
+
if (!value || typeof value !== 'object')
|
|
95
|
+
return value;
|
|
96
|
+
if (seen.has(value))
|
|
97
|
+
return '[Circular]';
|
|
98
|
+
seen.add(value);
|
|
99
|
+
if (Array.isArray(value))
|
|
100
|
+
return value.map((item) => this.redact(item, seen));
|
|
101
|
+
const keys = new Set([...(this.options.redact ?? []), ...DEFAULT_REDACT_KEYS].map((key) => key.toLowerCase()));
|
|
102
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [
|
|
103
|
+
key,
|
|
104
|
+
keys.has(key.toLowerCase()) ? '[Redacted]' : this.redact(item, seen),
|
|
105
|
+
]));
|
|
106
|
+
}
|
|
107
|
+
truncate(value) {
|
|
108
|
+
const max = this.options.maxBodySize ?? 4096;
|
|
109
|
+
const text = JSON.stringify(value);
|
|
110
|
+
if (!text || text.length <= max)
|
|
111
|
+
return value;
|
|
112
|
+
return `${text.slice(0, max)}...[Truncated]`;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
exports.NestLogsMiddleware = NestLogsMiddleware;
|
|
116
|
+
exports.NestLogsMiddleware = NestLogsMiddleware = __decorate([
|
|
117
|
+
(0, common_1.Injectable)(),
|
|
118
|
+
__param(1, (0, common_1.Inject)(nest_logs_logger_1.NEST_LOGS_OPTIONS)),
|
|
119
|
+
__metadata("design:paramtypes", [nest_logs_logger_1.NestLogsLogger, Object])
|
|
120
|
+
], NestLogsMiddleware);
|
|
121
|
+
//# sourceMappingURL=nest-logs.middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nest-logs.middleware.js","sourceRoot":"","sources":["../../src/nest-logs/nest-logs.middleware.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoE;AAEpE,yDAAuE;AAGvE,MAAM,mBAAmB,GAAG;IAC1B,eAAe;IACf,QAAQ;IACR,YAAY;IACZ,UAAU;IACV,OAAO;IACP,QAAQ;IACR,SAAS;IACT,WAAW;CACZ,CAAC;AAGK,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAEV;IAC2B;IAF9C,YACmB,MAAsB,EACK,OAAwB;QADnD,WAAM,GAAN,MAAM,CAAgB;QACK,YAAO,GAAP,OAAO,CAAiB;IACnE,CAAC;IAEJ,GAAG,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB;QACjD,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,OAAO,IAAI,EAAE,CAAC;QAEzE,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC7B,IAAI,QAAQ,GAAG,KAAK,CAAC;QACrB,IAAI,YAAqB,CAAC;QAE1B,IAAI,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,CAAC;YACrC,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,IAA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AM,CAAC,IAAI,EAAE,IAAI,CAAC;SACrE,CAAC,CACH,CAAC;IACJ,CAAC;IAEO,QAAQ,CAAC,KAAc;QAC7B,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,IAAI,IAAI,CAAC;QAC7C,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,IAAI,GAAG;YAAE,OAAO,KAAK,CAAC;QAC9C,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,gBAAgB,CAAC;IAC/C,CAAC;CACF,CAAA;AA/FY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;IAIR,WAAA,IAAA,eAAM,EAAC,oCAAiB,CAAC,CAAA;qCADD,iCAAc;GAF9B,kBAAkB,CA+F9B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DynamicModule, MiddlewareConsumer, NestModule } from '@nestjs/common';
|
|
2
|
+
import type { NestLogsOptions } from './nest-logs.interfaces';
|
|
3
|
+
export declare class NestLogsModule implements NestModule {
|
|
4
|
+
configure(consumer: MiddlewareConsumer): void;
|
|
5
|
+
static register(options: NestLogsOptions): DynamicModule;
|
|
6
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var NestLogsModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.NestLogsModule = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const nest_logs_controller_1 = require("./nest-logs.controller");
|
|
13
|
+
const nest_logs_logger_1 = require("./nest-logs.logger");
|
|
14
|
+
const nest_logs_middleware_1 = require("./nest-logs.middleware");
|
|
15
|
+
let NestLogsModule = NestLogsModule_1 = class NestLogsModule {
|
|
16
|
+
configure(consumer) {
|
|
17
|
+
consumer.apply(nest_logs_middleware_1.NestLogsMiddleware).forRoutes('*');
|
|
18
|
+
}
|
|
19
|
+
static register(options) {
|
|
20
|
+
const path = (options.path ?? '/nest-logs').replace(/^\//, '');
|
|
21
|
+
Reflect.defineMetadata('path', path, nest_logs_controller_1.NestLogsController);
|
|
22
|
+
return {
|
|
23
|
+
module: NestLogsModule_1,
|
|
24
|
+
controllers: [nest_logs_controller_1.NestLogsController],
|
|
25
|
+
providers: [
|
|
26
|
+
{ provide: nest_logs_logger_1.NEST_LOGS_OPTIONS, useValue: { ...options, path: `/${path}` } },
|
|
27
|
+
nest_logs_logger_1.NestLogsLogger,
|
|
28
|
+
nest_logs_middleware_1.NestLogsMiddleware,
|
|
29
|
+
],
|
|
30
|
+
exports: [nest_logs_logger_1.NestLogsLogger],
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
exports.NestLogsModule = NestLogsModule;
|
|
35
|
+
exports.NestLogsModule = NestLogsModule = NestLogsModule_1 = __decorate([
|
|
36
|
+
(0, common_1.Module)({})
|
|
37
|
+
], NestLogsModule);
|
|
38
|
+
//# sourceMappingURL=nest-logs.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nest-logs.module.js","sourceRoot":"","sources":["../../src/nest-logs/nest-logs.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAuF;AACvF,iEAA4D;AAC5D,yDAAuE;AACvE,iEAA4D;AAIrD,IAAM,cAAc,sBAApB,MAAM,cAAc;IACzB,SAAS,CAAC,QAA4B;QACpC,QAAQ,CAAC,KAAK,CAAC,yCAAkB,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IACpD,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,OAAwB;QACtC,MAAM,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,YAAY,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAE/D,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,yCAAkB,CAAC,CAAC;QAEzD,OAAO;YACL,MAAM,EAAE,gBAAc;YACtB,WAAW,EAAE,CAAC,yCAAkB,CAAC;YACjC,SAAS,EAAE;gBACT,EAAE,OAAO,EAAE,oCAAiB,EAAE,QAAQ,EAAE,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,IAAI,IAAI,EAAE,EAAE,EAAE;gBAC1E,iCAAc;gBACd,yCAAkB;aACnB;YACD,OAAO,EAAE,CAAC,iCAAc,CAAC;SAC1B,CAAC;IACJ,CAAC;CACF,CAAA;AArBY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,cAAc,CAqB1B"}
|
package/package.json
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "loglyn",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Production runtime logs for NestJS with an embedded dashboard.",
|
|
5
|
+
"author": "",
|
|
6
|
+
"private": false,
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"nestjs",
|
|
10
|
+
"logger",
|
|
11
|
+
"logs",
|
|
12
|
+
"dashboard",
|
|
13
|
+
"monitoring"
|
|
14
|
+
],
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"main": "./dist/index.js",
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"default": "./dist/index.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist/**/*.js",
|
|
28
|
+
"dist/**/*.d.ts",
|
|
29
|
+
"dist/**/*.js.map",
|
|
30
|
+
"client/dist",
|
|
31
|
+
"README.md"
|
|
32
|
+
],
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "nest build",
|
|
35
|
+
"build:client": "node scripts/build-client.cjs",
|
|
36
|
+
"build:package": "npm run build:client && npm run build",
|
|
37
|
+
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
38
|
+
"lint": "eslint \"{src,test}/**/*.ts\" --fix",
|
|
39
|
+
"test": "jest",
|
|
40
|
+
"prepack": "npm run build:package",
|
|
41
|
+
"prepublishOnly": "npm run build:package && npm test"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"@nestjs/common": "^11.0.1",
|
|
45
|
+
"@nestjs/core": "^11.0.1",
|
|
46
|
+
"reflect-metadata": "^0.2.2",
|
|
47
|
+
"rxjs": "^7.8.1"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"lodash": "^4.18.1",
|
|
51
|
+
"moment-timezone": "^0.6.2"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@eslint/eslintrc": "^3.2.0",
|
|
55
|
+
"@eslint/js": "^9.18.0",
|
|
56
|
+
"@nestjs/cli": "^11.0.0",
|
|
57
|
+
"@nestjs/platform-express": "^11.0.1",
|
|
58
|
+
"@nestjs/schematics": "^11.0.0",
|
|
59
|
+
"@nestjs/testing": "^11.0.1",
|
|
60
|
+
"@types/express": "^5.0.0",
|
|
61
|
+
"@types/jest": "^30.0.0",
|
|
62
|
+
"@types/lodash": "^4.17.24",
|
|
63
|
+
"@types/node": "^24.0.0",
|
|
64
|
+
"@types/supertest": "^7.0.0",
|
|
65
|
+
"eslint": "^9.18.0",
|
|
66
|
+
"eslint-config-prettier": "^10.0.1",
|
|
67
|
+
"eslint-plugin-prettier": "^5.2.2",
|
|
68
|
+
"globals": "^17.0.0",
|
|
69
|
+
"jest": "^30.0.0",
|
|
70
|
+
"prettier": "^3.4.2",
|
|
71
|
+
"source-map-support": "^0.5.21",
|
|
72
|
+
"supertest": "^7.0.0",
|
|
73
|
+
"ts-jest": "^29.2.5",
|
|
74
|
+
"ts-loader": "^9.5.2",
|
|
75
|
+
"ts-node": "^10.9.2",
|
|
76
|
+
"tsconfig-paths": "^4.2.0",
|
|
77
|
+
"typescript": "^5.7.3",
|
|
78
|
+
"typescript-eslint": "^8.20.0"
|
|
79
|
+
},
|
|
80
|
+
"jest": {
|
|
81
|
+
"moduleFileExtensions": [
|
|
82
|
+
"js",
|
|
83
|
+
"json",
|
|
84
|
+
"ts"
|
|
85
|
+
],
|
|
86
|
+
"rootDir": "src",
|
|
87
|
+
"testRegex": ".*\\.spec\\.ts$",
|
|
88
|
+
"transform": {
|
|
89
|
+
"^.+\\.(t|j)s$": "ts-jest"
|
|
90
|
+
},
|
|
91
|
+
"collectCoverageFrom": [
|
|
92
|
+
"**/*.(t|j)s"
|
|
93
|
+
],
|
|
94
|
+
"coverageDirectory": "../coverage",
|
|
95
|
+
"testEnvironment": "node"
|
|
96
|
+
}
|
|
97
|
+
}
|