nestjs-profiler 1.0.12 → 1.0.14

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.
Files changed (53) hide show
  1. package/analyzers/explain-analyzer.d.ts +5 -0
  2. package/analyzers/explain-analyzer.js +41 -0
  3. package/analyzers/explain-analyzer.js.map +1 -0
  4. package/controllers/profiler.controller.d.ts +34 -0
  5. package/controllers/profiler.controller.js +254 -0
  6. package/controllers/profiler.controller.js.map +1 -0
  7. package/package.json +9 -6
  8. package/profiler-logger.d.ts +12 -0
  9. package/profiler-logger.js +59 -0
  10. package/profiler-logger.js.map +1 -0
  11. package/profiler.module.d.ts +7 -0
  12. package/profiler.module.js +105 -0
  13. package/profiler.module.js.map +1 -0
  14. package/services/entity-explorer.service.d.ts +19 -0
  15. package/services/entity-explorer.service.js +111 -0
  16. package/services/entity-explorer.service.js.map +1 -0
  17. package/services/profiler.service.d.ts +31 -0
  18. package/services/profiler.service.js +216 -0
  19. package/services/profiler.service.js.map +1 -0
  20. package/services/route-explorer.service.d.ts +15 -0
  21. package/services/route-explorer.service.js +94 -0
  22. package/services/route-explorer.service.js.map +1 -0
  23. package/services/template-builder.service.d.ts +27 -0
  24. package/services/template-builder.service.js +348 -0
  25. package/services/template-builder.service.js.map +1 -0
  26. package/services/view.service.d.ts +17 -0
  27. package/services/view.service.js +196 -0
  28. package/services/view.service.js.map +1 -0
  29. /package/{src/assets → assets}/favicon.ico +0 -0
  30. /package/{src/assets → assets}/logo.png +0 -0
  31. /package/{src/views → views}/cache.html +0 -0
  32. /package/{src/views → views}/dashboard.html +0 -0
  33. /package/{src/views → views}/detail.html +0 -0
  34. /package/{src/views → views}/entities.html +0 -0
  35. /package/{src/views → views}/js/dashboard.js +0 -0
  36. /package/{src/views → views}/js/entities.js +0 -0
  37. /package/{src/views → views}/js/layout-config.js +0 -0
  38. /package/{src/views → views}/js/layout.js +0 -0
  39. /package/{src/views → views}/js/queries.js +0 -0
  40. /package/{src/views → views}/layout.html +0 -0
  41. /package/{src/views → views}/logs.html +0 -0
  42. /package/{src/views → views}/not_found.html +0 -0
  43. /package/{src/views → views}/partials/cache_row.html +0 -0
  44. /package/{src/views → views}/partials/detail_query_row.html +0 -0
  45. /package/{src/views → views}/partials/entity_row.html +0 -0
  46. /package/{src/views → views}/partials/log_row.html +0 -0
  47. /package/{src/views → views}/partials/metadata_sidebar.html +0 -0
  48. /package/{src/views → views}/partials/pagination.html +0 -0
  49. /package/{src/views → views}/partials/query_row.html +0 -0
  50. /package/{src/views → views}/partials/request_row.html +0 -0
  51. /package/{src/views → views}/partials/route_row.html +0 -0
  52. /package/{src/views → views}/queries.html +0 -0
  53. /package/{src/views → views}/routes.html +0 -0
@@ -0,0 +1,5 @@
1
+ import * as pg from 'pg';
2
+ export declare class ExplainAnalyzer {
3
+ private readonly logger;
4
+ analyze(client: pg.Client | pg.PoolClient, query: string, params: any[], useAnalyze?: boolean): Promise<any>;
5
+ }
@@ -0,0 +1,41 @@
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 ExplainAnalyzer_1;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.ExplainAnalyzer = void 0;
11
+ const common_1 = require("@nestjs/common");
12
+ let ExplainAnalyzer = ExplainAnalyzer_1 = class ExplainAnalyzer {
13
+ constructor() {
14
+ this.logger = new common_1.Logger(ExplainAnalyzer_1.name);
15
+ }
16
+ async analyze(client, query, params, useAnalyze = false) {
17
+ try {
18
+ const cmd = useAnalyze ? 'EXPLAIN (ANALYZE, FORMAT JSON)' : 'EXPLAIN (FORMAT JSON)';
19
+ const explainSql = `${cmd} ${query}`;
20
+ const result = await client.query(explainSql, params);
21
+ if (result.rows && result.rows.length > 0) {
22
+ return result.rows[0]['QUERY PLAN'];
23
+ }
24
+ return null;
25
+ }
26
+ catch (e) {
27
+ if (e.message.includes('closed') || e.message.includes('terminated')) {
28
+ return null;
29
+ }
30
+ if (process.env.PROFILER_DEBUG) {
31
+ this.logger.warn(`Failed to run EXPLAIN: ${e.message}`);
32
+ }
33
+ return null;
34
+ }
35
+ }
36
+ };
37
+ exports.ExplainAnalyzer = ExplainAnalyzer;
38
+ exports.ExplainAnalyzer = ExplainAnalyzer = ExplainAnalyzer_1 = __decorate([
39
+ (0, common_1.Injectable)()
40
+ ], ExplainAnalyzer);
41
+ //# sourceMappingURL=explain-analyzer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"explain-analyzer.js","sourceRoot":"","sources":["../../../libs/nestjs-profiler/src/analyzers/explain-analyzer.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAoD;AAI7C,IAAM,eAAe,uBAArB,MAAM,eAAe;IAArB;QACc,WAAM,GAAG,IAAI,eAAM,CAAC,iBAAe,CAAC,IAAI,CAAC,CAAC;IA2B/D,CAAC;IAzBG,KAAK,CAAC,OAAO,CACT,MAAiC,EACjC,KAAa,EACb,MAAa,EACb,aAAsB,KAAK;QAE3B,IAAI,CAAC;YACD,MAAM,GAAG,GAAG,UAAU,CAAC,CAAC,CAAC,gCAAgC,CAAC,CAAC,CAAC,uBAAuB,CAAC;YACpF,MAAM,UAAU,GAAG,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;YAErC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;YACtD,IAAI,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACxC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;YACxC,CAAC;YACD,OAAO,IAAI,CAAC;QAChB,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YACd,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;gBACnE,OAAO,IAAI,CAAC;YAChB,CAAC;YACD,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC;gBAC7B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;YAC5D,CAAC;YACD,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;CACJ,CAAA;AA5BY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;GACA,eAAe,CA4B3B"}
@@ -0,0 +1,34 @@
1
+ import type { Response } from 'express';
2
+ import { ProfilerService } from '../services/profiler.service';
3
+ import { ViewService } from '../services/view.service';
4
+ import { TemplateBuilderService } from '../services/template-builder.service';
5
+ import { EntityExplorerService } from '../services/entity-explorer.service';
6
+ import { RouteExplorerService } from '../services/route-explorer.service';
7
+ export declare class ProfilerController {
8
+ private readonly profilerService;
9
+ private readonly viewService;
10
+ private readonly templateBuilder;
11
+ private readonly entityExplorer;
12
+ private readonly routeExplorer;
13
+ constructor(profilerService: ProfilerService, viewService: ViewService, templateBuilder: TemplateBuilderService, entityExplorer: EntityExplorerService, routeExplorer: RouteExplorerService);
14
+ dashboard(res: Response): Promise<void>;
15
+ listJson(): Promise<import("..").RequestProfile[]>;
16
+ debugQuery(): Promise<{
17
+ status: string;
18
+ message: string;
19
+ tip?: undefined;
20
+ } | {
21
+ status: string;
22
+ message: string;
23
+ tip: string;
24
+ }>;
25
+ detail(id: string, res: Response): Promise<void>;
26
+ detailJson(id: string): Promise<import("..").RequestProfile>;
27
+ listQueries(res: Response): Promise<void>;
28
+ listLogs(res: Response, page?: number): Promise<void>;
29
+ listEntities(res: Response): Promise<void>;
30
+ listRoutes(res: Response): Promise<void>;
31
+ listCache(res: Response): Promise<void>;
32
+ serveAsset(file: string, res: Response): Promise<void>;
33
+ serveJs(file: string, res: Response): Promise<void>;
34
+ }
@@ -0,0 +1,254 @@
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.ProfilerController = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const profiler_service_1 = require("../services/profiler.service");
18
+ const view_service_1 = require("../services/view.service");
19
+ const template_builder_service_1 = require("../services/template-builder.service");
20
+ const entity_explorer_service_1 = require("../services/entity-explorer.service");
21
+ const route_explorer_service_1 = require("../services/route-explorer.service");
22
+ let ProfilerController = class ProfilerController {
23
+ constructor(profilerService, viewService, templateBuilder, entityExplorer, routeExplorer) {
24
+ this.profilerService = profilerService;
25
+ this.viewService = viewService;
26
+ this.templateBuilder = templateBuilder;
27
+ this.entityExplorer = entityExplorer;
28
+ this.routeExplorer = routeExplorer;
29
+ }
30
+ async dashboard(res) {
31
+ const profiles = await this.profilerService.getDashboardData();
32
+ const content = this.templateBuilder.buildDashboard(profiles);
33
+ const html = this.viewService.renderWithLayout('Requests', content, 'requests');
34
+ res.header('Content-Type', 'text/html');
35
+ res.send(html);
36
+ }
37
+ async listJson() {
38
+ return this.profilerService.getAllProfilesJson();
39
+ }
40
+ async debugQuery() {
41
+ const { Client } = require('pg');
42
+ const client = new Client({
43
+ host: process.env.DB_HOST || 'localhost',
44
+ port: 5432,
45
+ user: process.env.DB_USER || 'postgres',
46
+ password: process.env.DB_PASSWORD || 'postgres',
47
+ database: process.env.DB_NAME || 'postgres',
48
+ });
49
+ try {
50
+ await client.connect();
51
+ await client.query('SELECT 1 as test_query');
52
+ await client.end();
53
+ return { status: 'success', message: 'Query executed. Check profiler.' };
54
+ }
55
+ catch (e) {
56
+ return {
57
+ status: 'error',
58
+ message: `Connection failed: ${e.message}`,
59
+ tip: 'Pass correct credentials in URL: ?user=YOUR_USER&password=YOUR_PASS&database=YOUR_DB'
60
+ };
61
+ }
62
+ }
63
+ async detail(id, res) {
64
+ const profile = await this.profilerService.getProfileDetail(id);
65
+ if (!profile) {
66
+ const content = this.templateBuilder.buildNotFound(id);
67
+ const html = this.viewService.renderWithLayout('Profile Not Found', content);
68
+ res.header('Content-Type', 'text/html');
69
+ res.status(common_1.HttpStatus.NOT_FOUND).send(html);
70
+ return;
71
+ }
72
+ const content = this.templateBuilder.buildDetail(profile);
73
+ const html = this.viewService.renderWithLayout(`Request ${profile.id}`, content);
74
+ res.header('Content-Type', 'text/html');
75
+ res.send(html);
76
+ }
77
+ async detailJson(id) {
78
+ const profile = await this.profilerService.getProfileJson(id);
79
+ if (!profile)
80
+ throw new common_1.NotFoundException('Profile not found');
81
+ return profile;
82
+ }
83
+ async listQueries(res) {
84
+ const queries = await this.profilerService.getQueriesList();
85
+ const content = this.templateBuilder.buildQueriesList(queries);
86
+ const html = this.viewService.renderWithLayout('Database Queries', content, 'queries');
87
+ res.header('Content-Type', 'text/html');
88
+ res.send(html);
89
+ }
90
+ async listLogs(res, page = 1) {
91
+ const { logs, currentPage, totalPages, totalLogs } = await this.profilerService.getLogsList(page);
92
+ const content = this.templateBuilder.buildLogsList(logs, currentPage, totalPages, totalLogs);
93
+ const html = this.viewService.renderWithLayout('Application Logs', content, 'logs');
94
+ res.header('Content-Type', 'text/html');
95
+ res.send(html);
96
+ }
97
+ async listEntities(res) {
98
+ const entities = this.entityExplorer.getEntities();
99
+ const content = this.templateBuilder.buildEntitiesList(entities);
100
+ const html = this.viewService.renderWithLayout('Entity Explorer', content, 'entities');
101
+ res.header('Content-Type', 'text/html');
102
+ res.send(html);
103
+ }
104
+ async listRoutes(res) {
105
+ const routes = this.routeExplorer.getRoutes();
106
+ const content = this.templateBuilder.buildRoutesList(routes);
107
+ const html = this.viewService.renderWithLayout('Routes Explorer', content, 'routes');
108
+ res.header('Content-Type', 'text/html');
109
+ res.send(html);
110
+ }
111
+ async listCache(res) {
112
+ const cacheOps = await this.profilerService.getCacheList();
113
+ const content = this.templateBuilder.buildCacheList(cacheOps);
114
+ const html = this.viewService.renderWithLayout('Cache Operations', content, 'cache');
115
+ res.header('Content-Type', 'text/html');
116
+ res.send(html);
117
+ }
118
+ async serveAsset(file, res) {
119
+ const fs = require('fs');
120
+ const path = require('path');
121
+ const assetsPath = path.join(__dirname, '..', 'assets');
122
+ const filePath = path.join(assetsPath, file);
123
+ if (fs.existsSync(filePath)) {
124
+ const ext = path.extname(file);
125
+ let contentType = 'text/plain';
126
+ if (ext === '.png')
127
+ contentType = 'image/png';
128
+ if (ext === '.ico')
129
+ contentType = 'image/x-icon';
130
+ if (ext === '.svg')
131
+ contentType = 'image/svg+xml';
132
+ if (ext === '.css')
133
+ contentType = 'text/css';
134
+ if (ext === '.js')
135
+ contentType = 'text/javascript';
136
+ res.header('Content-Type', contentType);
137
+ res.header('Cache-Control', 'public, max-age=86400');
138
+ fs.createReadStream(filePath).pipe(res);
139
+ }
140
+ else {
141
+ res.status(common_1.HttpStatus.NOT_FOUND).send('Asset not found');
142
+ }
143
+ }
144
+ async serveJs(file, res) {
145
+ const fs = require('fs');
146
+ const path = require('path');
147
+ const jsPath = path.join(__dirname, '..', 'views', 'js');
148
+ const filePath = path.join(jsPath, file);
149
+ if (fs.existsSync(filePath)) {
150
+ res.header('Content-Type', 'text/javascript');
151
+ res.header('Cache-Control', 'public, max-age=86400');
152
+ fs.createReadStream(filePath).pipe(res);
153
+ }
154
+ else {
155
+ res.status(common_1.HttpStatus.NOT_FOUND).send('Script not found');
156
+ }
157
+ }
158
+ };
159
+ exports.ProfilerController = ProfilerController;
160
+ __decorate([
161
+ (0, common_1.Get)(),
162
+ __param(0, (0, common_1.Res)()),
163
+ __metadata("design:type", Function),
164
+ __metadata("design:paramtypes", [Object]),
165
+ __metadata("design:returntype", Promise)
166
+ ], ProfilerController.prototype, "dashboard", null);
167
+ __decorate([
168
+ (0, common_1.Get)('json'),
169
+ __metadata("design:type", Function),
170
+ __metadata("design:paramtypes", []),
171
+ __metadata("design:returntype", Promise)
172
+ ], ProfilerController.prototype, "listJson", null);
173
+ __decorate([
174
+ (0, common_1.Get)('debug/test-query'),
175
+ __metadata("design:type", Function),
176
+ __metadata("design:paramtypes", []),
177
+ __metadata("design:returntype", Promise)
178
+ ], ProfilerController.prototype, "debugQuery", null);
179
+ __decorate([
180
+ (0, common_1.Get)(':id'),
181
+ __param(0, (0, common_1.Param)('id')),
182
+ __param(1, (0, common_1.Res)()),
183
+ __metadata("design:type", Function),
184
+ __metadata("design:paramtypes", [String, Object]),
185
+ __metadata("design:returntype", Promise)
186
+ ], ProfilerController.prototype, "detail", null);
187
+ __decorate([
188
+ (0, common_1.Get)(':id/json'),
189
+ __param(0, (0, common_1.Param)('id')),
190
+ __metadata("design:type", Function),
191
+ __metadata("design:paramtypes", [String]),
192
+ __metadata("design:returntype", Promise)
193
+ ], ProfilerController.prototype, "detailJson", null);
194
+ __decorate([
195
+ (0, common_1.Get)('view/queries'),
196
+ __param(0, (0, common_1.Res)()),
197
+ __metadata("design:type", Function),
198
+ __metadata("design:paramtypes", [Object]),
199
+ __metadata("design:returntype", Promise)
200
+ ], ProfilerController.prototype, "listQueries", null);
201
+ __decorate([
202
+ (0, common_1.Get)('view/logs'),
203
+ __param(0, (0, common_1.Res)()),
204
+ __param(1, (0, common_1.Query)('page')),
205
+ __metadata("design:type", Function),
206
+ __metadata("design:paramtypes", [Object, Number]),
207
+ __metadata("design:returntype", Promise)
208
+ ], ProfilerController.prototype, "listLogs", null);
209
+ __decorate([
210
+ (0, common_1.Get)('view/entities'),
211
+ __param(0, (0, common_1.Res)()),
212
+ __metadata("design:type", Function),
213
+ __metadata("design:paramtypes", [Object]),
214
+ __metadata("design:returntype", Promise)
215
+ ], ProfilerController.prototype, "listEntities", null);
216
+ __decorate([
217
+ (0, common_1.Get)('view/routes'),
218
+ __param(0, (0, common_1.Res)()),
219
+ __metadata("design:type", Function),
220
+ __metadata("design:paramtypes", [Object]),
221
+ __metadata("design:returntype", Promise)
222
+ ], ProfilerController.prototype, "listRoutes", null);
223
+ __decorate([
224
+ (0, common_1.Get)('view/cache'),
225
+ __param(0, (0, common_1.Res)()),
226
+ __metadata("design:type", Function),
227
+ __metadata("design:paramtypes", [Object]),
228
+ __metadata("design:returntype", Promise)
229
+ ], ProfilerController.prototype, "listCache", null);
230
+ __decorate([
231
+ (0, common_1.Get)('assets/:file'),
232
+ __param(0, (0, common_1.Param)('file')),
233
+ __param(1, (0, common_1.Res)()),
234
+ __metadata("design:type", Function),
235
+ __metadata("design:paramtypes", [String, Object]),
236
+ __metadata("design:returntype", Promise)
237
+ ], ProfilerController.prototype, "serveAsset", null);
238
+ __decorate([
239
+ (0, common_1.Get)('js/:file'),
240
+ __param(0, (0, common_1.Param)('file')),
241
+ __param(1, (0, common_1.Res)()),
242
+ __metadata("design:type", Function),
243
+ __metadata("design:paramtypes", [String, Object]),
244
+ __metadata("design:returntype", Promise)
245
+ ], ProfilerController.prototype, "serveJs", null);
246
+ exports.ProfilerController = ProfilerController = __decorate([
247
+ (0, common_1.Controller)('__profiler'),
248
+ __metadata("design:paramtypes", [profiler_service_1.ProfilerService,
249
+ view_service_1.ViewService,
250
+ template_builder_service_1.TemplateBuilderService,
251
+ entity_explorer_service_1.EntityExplorerService,
252
+ route_explorer_service_1.RouteExplorerService])
253
+ ], ProfilerController);
254
+ //# sourceMappingURL=profiler.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profiler.controller.js","sourceRoot":"","sources":["../../../libs/nestjs-profiler/src/controllers/profiler.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA2G;AAE3G,mEAA+D;AAC/D,2DAAuD;AACvD,mFAA8E;AAC9E,iFAA4E;AAE5E,+EAA0E;AAGnE,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC3B,YACqB,eAAgC,EAChC,WAAwB,EACxB,eAAuC,EACvC,cAAqC,EACrC,aAAmC;QAJnC,oBAAe,GAAf,eAAe,CAAiB;QAChC,gBAAW,GAAX,WAAW,CAAa;QACxB,oBAAe,GAAf,eAAe,CAAwB;QACvC,mBAAc,GAAd,cAAc,CAAuB;QACrC,kBAAa,GAAb,aAAa,CAAsB;IACpD,CAAC;IAGC,AAAN,KAAK,CAAC,SAAS,CAAQ,GAAa;QAChC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,gBAAgB,EAAE,CAAC;QAC/D,MAAM,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QAC9D,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,UAAU,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QAEhF,GAAG,CAAC,MAAM,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;QACxC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC;IAGK,AAAN,KAAK,CAAC,QAAQ;QACV,OAAO,IAAI,CAAC,eAAe,CAAC,k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AGiB,kCAAe;QACnB,0BAAW;QACP,iDAAsB;QACvB,+CAAqB;QACtB,6CAAoB;GAN/C,kBAAkB,CAqK9B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nestjs-profiler",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "description": "A NestJS module for profiling HTTP requests, database queries, and cache operations. Inspired by Symfony Profiler, it provides a web-based dashboard to inspect request duration, executed queries, log messages, and explain plans for slow queries.",
5
5
  "author": "Mohamed Raslan",
6
6
  "main": "./index.js",
@@ -17,11 +17,14 @@
17
17
  "access": "public"
18
18
  },
19
19
  "files": [
20
- "index.js",
21
- "index.d.ts",
22
- "index.js.map",
23
- "src/assets",
24
- "src/views",
20
+ "*.js",
21
+ "*.d.ts",
22
+ "*.js.map",
23
+ "assets",
24
+ "views",
25
+ "analyzers",
26
+ "controllers",
27
+ "services",
25
28
  "README.md"
26
29
  ],
27
30
  "peerDependencies": {
@@ -0,0 +1,12 @@
1
+ import { ConsoleLogger } from '@nestjs/common';
2
+ import { ProfilerService } from './services/profiler.service';
3
+ export declare class ProfilerLogger extends ConsoleLogger {
4
+ private profiler;
5
+ constructor(profiler: ProfilerService);
6
+ log(message: any, ...optionalParams: any[]): void;
7
+ error(message: any, ...optionalParams: any[]): void;
8
+ warn(message: any, ...optionalParams: any[]): void;
9
+ debug(message: any, ...optionalParams: any[]): void;
10
+ verbose(message: any, ...optionalParams: any[]): void;
11
+ private captureLog;
12
+ }
@@ -0,0 +1,59 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ProfilerLogger = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const profiler_service_1 = require("./services/profiler.service");
15
+ let ProfilerLogger = class ProfilerLogger extends common_1.ConsoleLogger {
16
+ constructor(profiler) {
17
+ super();
18
+ this.profiler = profiler;
19
+ }
20
+ log(message, ...optionalParams) {
21
+ super.log(message, ...optionalParams);
22
+ this.captureLog('log', message, optionalParams);
23
+ }
24
+ error(message, ...optionalParams) {
25
+ super.error(message, ...optionalParams);
26
+ this.captureLog('error', message, optionalParams);
27
+ }
28
+ warn(message, ...optionalParams) {
29
+ super.warn(message, ...optionalParams);
30
+ this.captureLog('warn', message, optionalParams);
31
+ }
32
+ debug(message, ...optionalParams) {
33
+ super.debug(message, ...optionalParams);
34
+ this.captureLog('debug', message, optionalParams);
35
+ }
36
+ verbose(message, ...optionalParams) {
37
+ super.verbose(message, ...optionalParams);
38
+ this.captureLog('verbose', message, optionalParams);
39
+ }
40
+ captureLog(level, message, params) {
41
+ try {
42
+ const context = params.length > 0 ? params[params.length - 1] : undefined;
43
+ const msgStr = typeof message === 'object' ? JSON.stringify(message) : String(message);
44
+ this.profiler.addLog({
45
+ level,
46
+ message: msgStr,
47
+ context: typeof context === 'string' ? context : undefined,
48
+ timestamp: Date.now()
49
+ });
50
+ }
51
+ catch (e) { }
52
+ }
53
+ };
54
+ exports.ProfilerLogger = ProfilerLogger;
55
+ exports.ProfilerLogger = ProfilerLogger = __decorate([
56
+ (0, common_1.Injectable)({ scope: common_1.Scope.TRANSIENT }),
57
+ __metadata("design:paramtypes", [profiler_service_1.ProfilerService])
58
+ ], ProfilerLogger);
59
+ //# sourceMappingURL=profiler-logger.js.map
@@ -0,0 +1 @@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xD,CAAC;IAEO,UAAU,CAAC,KAAa,EAAE,OAAY,EAAE,MAAa;QACzD,IAAI,CAAC;YACD,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YAE1E,MAAM,MAAM,GAAG,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAEvF,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;gBACjB,KAAK;gBACL,OAAO,EAAE,MAAM;gBACf,OAAO,EAAE,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;gBAC1D,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;aACxB,CAAC,CAAC;QACP,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;IACnB,CAAC;CACJ,CAAA;AA5CY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,EAAC,EAAE,KAAK,EAAE,cAAK,CAAC,SAAS,EAAE,CAAC;qCAEL,kCAAe;GADpC,cAAc,CA4C1B"}
@@ -0,0 +1,7 @@
1
+ import { DynamicModule, MiddlewareConsumer, NestModule } from '@nestjs/common';
2
+ import { ProfilerOptions } from './common/profiler-options.interface';
3
+ export declare class ProfilerModule implements NestModule {
4
+ configure(consumer: MiddlewareConsumer): void;
5
+ static forRoot(options?: ProfilerOptions): DynamicModule;
6
+ static initialize(app: any): void;
7
+ }
@@ -0,0 +1,105 @@
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 ProfilerModule_1;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.ProfilerModule = void 0;
11
+ const common_1 = require("@nestjs/common");
12
+ const profiler_service_1 = require("./services/profiler.service");
13
+ const view_service_1 = require("./services/view.service");
14
+ const template_builder_service_1 = require("./services/template-builder.service");
15
+ const entity_explorer_service_1 = require("./services/entity-explorer.service");
16
+ const route_explorer_service_1 = require("./services/route-explorer.service");
17
+ const postgres_collector_1 = require("./collectors/postgres-collector");
18
+ const mongo_collector_1 = require("./collectors/mongo-collector");
19
+ const mysql_collector_1 = require("./collectors/mysql-collector");
20
+ const log_collector_1 = require("./collectors/log-collector");
21
+ const cache_collector_1 = require("./collectors/cache-collector");
22
+ const explain_analyzer_1 = require("./analyzers/explain-analyzer");
23
+ const in_memory_profiler_storage_1 = require("./storage/in-memory-profiler-storage");
24
+ const profiler_controller_1 = require("./controllers/profiler.controller");
25
+ const request_profiler_interceptor_1 = require("./interceptors/request-profiler.interceptor");
26
+ const core_1 = require("@nestjs/core");
27
+ const profiler_logger_1 = require("./profiler-logger");
28
+ const profiler_middleware_1 = require("./middleware/profiler.middleware");
29
+ let ProfilerModule = ProfilerModule_1 = class ProfilerModule {
30
+ configure(consumer) {
31
+ consumer
32
+ .apply(profiler_middleware_1.ProfilerMiddleware)
33
+ .exclude({ path: '__profiler/(.*)', method: common_1.RequestMethod.ALL })
34
+ .forRoutes({ path: '*', method: common_1.RequestMethod.ALL });
35
+ }
36
+ static forRoot(options = {}) {
37
+ const optionsProvider = {
38
+ provide: 'PROFILER_OPTIONS',
39
+ useValue: options,
40
+ };
41
+ const storageProvider = {
42
+ provide: 'PROFILER_STORAGE',
43
+ useValue: typeof options.storage === 'object' && options.storage !== null
44
+ ? options.storage
45
+ : new in_memory_profiler_storage_1.InMemoryProfilerStorage(),
46
+ };
47
+ return {
48
+ module: ProfilerModule_1,
49
+ imports: [],
50
+ providers: [
51
+ optionsProvider,
52
+ storageProvider,
53
+ profiler_service_1.ProfilerService,
54
+ view_service_1.ViewService,
55
+ template_builder_service_1.TemplateBuilderService,
56
+ entity_explorer_service_1.EntityExplorerService,
57
+ route_explorer_service_1.RouteExplorerService,
58
+ postgres_collector_1.PostgresCollector,
59
+ mongo_collector_1.MongoCollector,
60
+ mysql_collector_1.MysqlCollector,
61
+ log_collector_1.LogCollector,
62
+ cache_collector_1.CacheCollector,
63
+ explain_analyzer_1.ExplainAnalyzer,
64
+ {
65
+ provide: core_1.APP_INTERCEPTOR,
66
+ useClass: request_profiler_interceptor_1.RequestProfilerInterceptor,
67
+ },
68
+ ],
69
+ exports: [profiler_service_1.ProfilerService],
70
+ };
71
+ }
72
+ static initialize(app) {
73
+ try {
74
+ const container = app.container;
75
+ const modulesContainer = container.getModules();
76
+ const entityExplorer = app.get(entity_explorer_service_1.EntityExplorerService);
77
+ entityExplorer.initialize(modulesContainer);
78
+ const routeExplorer = app.get(route_explorer_service_1.RouteExplorerService);
79
+ const globalPrefix = app.config?.getGlobalPrefix
80
+ ? app.config.getGlobalPrefix()
81
+ : '';
82
+ routeExplorer.initialize(modulesContainer, globalPrefix);
83
+ }
84
+ catch (e) {
85
+ console.warn('Profiler: Could not initialize Explorers. Ensure ProfilerModule is imported.', e);
86
+ }
87
+ }
88
+ };
89
+ exports.ProfilerModule = ProfilerModule;
90
+ exports.ProfilerModule = ProfilerModule = ProfilerModule_1 = __decorate([
91
+ (0, common_1.Global)(),
92
+ (0, common_1.Module)({
93
+ controllers: [profiler_controller_1.ProfilerController],
94
+ providers: [
95
+ profiler_service_1.ProfilerService,
96
+ profiler_logger_1.ProfilerLogger,
97
+ view_service_1.ViewService,
98
+ template_builder_service_1.TemplateBuilderService,
99
+ entity_explorer_service_1.EntityExplorerService,
100
+ route_explorer_service_1.RouteExplorerService,
101
+ ],
102
+ exports: [profiler_service_1.ProfilerService, entity_explorer_service_1.EntityExplorerService, route_explorer_service_1.RouteExplorerService],
103
+ })
104
+ ], ProfilerModule);
105
+ //# sourceMappingURL=profiler.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profiler.module.js","sourceRoot":"","sources":["../../libs/nestjs-profiler/src/profiler.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAQwB;AAExB,kEAA8D;AAC9D,0DAAsD;AACtD,kFAA6E;AAC7E,gFAA2E;AAC3E,8EAAyE;AACzE,wEAAoE;AACpE,kEAA8D;AAC9D,kEAA8D;AAC9D,8DAA0D;AAC1D,kEAA8D;AAC9D,mEAA+D;AAC/D,qFAA+E;AAC/E,2EAAuE;AACvE,8FAAyF;AACzF,uCAA+C;AAC/C,uDAAmD;AACnD,0EAAsE;AAe/D,IAAM,cAAc,sBAApB,MAAM,cAAc;IACzB,SAAS,CAAC,QAA4B;QACpC,QAAQ;aACL,KAAK,CAAC,wCAAkB,CAAC;aACzB,OAAO,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,EAAE,sBAAa,CAAC,GAAG,EAAE,CAAC;aAC/D,SAAS,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,sBAAa,CAAC,GAAG,EAAE,CAAC,CAAC;IACzD,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,UAA2B,EAAE;QAC1C,MAAM,eAAe,GAAa;YAChC,OAAO,EAAE,kBAAkB;YAC3B,QAAQ,EAAE,OAAO;SAClB,CAAC;QAEF,MAAM,eAAe,GAAa;YAChC,OAAO,EAAE,kBAAkB;YAC3B,QAAQ,EACN,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,OAAO,KAAK,IAAI;gBAC7D,CAAC,CAAC,OAAO,CAAC,OAAO;gBACjB,CAAC,CAAC,IAAI,oDAAuB,EA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,kCAAe;YACf,gCAAc;YACd,0BAAW;YACX,iDAAsB;YACtB,+CAAqB;YACrB,6CAAoB;SACrB;QACD,OAAO,EAAE,CAAC,kCAAe,EAAE,+CAAqB,EAAE,6CAAoB,CAAC;KACxE,CAAC;GACW,cAAc,CA0E1B"}
@@ -0,0 +1,19 @@
1
+ export interface EntityDefinition {
2
+ name: string;
3
+ type: string;
4
+ database: string;
5
+ connection: string;
6
+ tableName?: string;
7
+ columns?: string[];
8
+ }
9
+ export declare class EntityExplorerService {
10
+ private entities;
11
+ constructor();
12
+ initialize(modulesContainer: any): void;
13
+ getEntities(): EntityDefinition[];
14
+ private scan;
15
+ private isTypeOrmDataSource;
16
+ private extractTypeOrmEntities;
17
+ private isMongooseConnection;
18
+ private extractMongooseModels;
19
+ }