nestjs-profiler 1.0.12 → 1.0.13
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/analyzers/explain-analyzer.d.ts +5 -0
- package/analyzers/explain-analyzer.js +41 -0
- package/analyzers/explain-analyzer.js.map +1 -0
- package/collectors/cache-collector.d.ts +18 -0
- package/collectors/cache-collector.js +175 -0
- package/collectors/cache-collector.js.map +1 -0
- package/collectors/log-collector.d.ts +12 -0
- package/collectors/log-collector.js +66 -0
- package/collectors/log-collector.js.map +1 -0
- package/collectors/mongo-collector.d.ts +19 -0
- package/collectors/mongo-collector.js +200 -0
- package/collectors/mongo-collector.js.map +1 -0
- package/collectors/mysql-collector.d.ts +12 -0
- package/collectors/mysql-collector.js +128 -0
- package/collectors/mysql-collector.js.map +1 -0
- package/collectors/postgres-collector.d.ts +15 -0
- package/collectors/postgres-collector.js +201 -0
- package/collectors/postgres-collector.js.map +1 -0
- package/common/profiler-options.interface.d.ts +20 -0
- package/common/profiler-options.interface.js +3 -0
- package/common/profiler-options.interface.js.map +1 -0
- package/common/profiler.model.d.ts +67 -0
- package/common/profiler.model.js +3 -0
- package/common/profiler.model.js.map +1 -0
- package/controllers/profiler.controller.d.ts +34 -0
- package/controllers/profiler.controller.js +254 -0
- package/controllers/profiler.controller.js.map +1 -0
- package/interceptors/request-profiler.interceptor.d.ts +11 -0
- package/interceptors/request-profiler.interceptor.js +103 -0
- package/interceptors/request-profiler.interceptor.js.map +1 -0
- package/middleware/profiler.middleware.d.ts +4 -0
- package/middleware/profiler.middleware.js +21 -0
- package/middleware/profiler.middleware.js.map +1 -0
- package/package.json +5 -4
- package/profiler-logger.d.ts +12 -0
- package/profiler-logger.js +59 -0
- package/profiler-logger.js.map +1 -0
- package/profiler.module.d.ts +7 -0
- package/profiler.module.js +105 -0
- package/profiler.module.js.map +1 -0
- package/services/entity-explorer.service.d.ts +19 -0
- package/services/entity-explorer.service.js +111 -0
- package/services/entity-explorer.service.js.map +1 -0
- package/services/profiler.service.d.ts +31 -0
- package/services/profiler.service.js +216 -0
- package/services/profiler.service.js.map +1 -0
- package/services/route-explorer.service.d.ts +15 -0
- package/services/route-explorer.service.js +94 -0
- package/services/route-explorer.service.js.map +1 -0
- package/services/template-builder.service.d.ts +27 -0
- package/services/template-builder.service.js +348 -0
- package/services/template-builder.service.js.map +1 -0
- package/services/view.service.d.ts +17 -0
- package/services/view.service.js +196 -0
- package/services/view.service.js.map +1 -0
- package/storage/in-memory-profiler-storage.d.ts +9 -0
- package/storage/in-memory-profiler-storage.js +29 -0
- package/storage/in-memory-profiler-storage.js.map +1 -0
- package/storage/profiler-storage.interface.d.ts +6 -0
- package/storage/profiler-storage.interface.js +3 -0
- package/storage/profiler-storage.interface.js.map +1 -0
|
@@ -0,0 +1,348 @@
|
|
|
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.TemplateBuilderService = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const view_service_1 = require("./view.service");
|
|
15
|
+
let TemplateBuilderService = class TemplateBuilderService {
|
|
16
|
+
constructor(viewService) {
|
|
17
|
+
this.viewService = viewService;
|
|
18
|
+
}
|
|
19
|
+
buildDashboard(profiles) {
|
|
20
|
+
const rows = profiles.map(p => this.buildRequestRow(p)).join('');
|
|
21
|
+
const emptyState = !rows ? '<div class="p-8 text-center text-gray-500">No requests captured yet.</div>' : '';
|
|
22
|
+
return this.viewService.render('dashboard', {
|
|
23
|
+
rows,
|
|
24
|
+
emptyState
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
buildDetail(profile) {
|
|
28
|
+
const queries = profile.queries.map((q, i) => this.buildQueryDetail(q, i)).join('') ||
|
|
29
|
+
'<div class="text-center text-gray-400 py-8 italic">No queries executed during this request.</div>';
|
|
30
|
+
const statusCode = profile.statusCode || 200;
|
|
31
|
+
const statusColor = this.getStatusColor(statusCode);
|
|
32
|
+
return this.viewService.render('detail', {
|
|
33
|
+
method: profile.method,
|
|
34
|
+
url: profile.url,
|
|
35
|
+
statusColor,
|
|
36
|
+
timeAgo: this.viewService.timeAgo(profile.timestamp),
|
|
37
|
+
queryCount: profile.queries.length,
|
|
38
|
+
queries,
|
|
39
|
+
sidebar: this.buildMetadataSidebar(profile),
|
|
40
|
+
headersTable: this.buildHeadersTable(profile.requestHeaders),
|
|
41
|
+
bodyView: this.buildBodyView(profile.requestBody),
|
|
42
|
+
exceptionView: this.buildExceptionView(profile.exception),
|
|
43
|
+
timingBar: this.buildTimingBar(profile.timings, profile.duration || 0),
|
|
44
|
+
cacheSection: this.buildCacheSection(profile.cache || [])
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
buildHeadersTable(headers) {
|
|
48
|
+
if (!headers || Object.keys(headers).length === 0)
|
|
49
|
+
return '<div class="text-gray-400 italic">No headers captured</div>';
|
|
50
|
+
const rows = Object.entries(headers).map(([key, value]) => `
|
|
51
|
+
<tr class="border-b border-gray-100 last:border-0">
|
|
52
|
+
<td class="py-2 px-3 text-xs font-semibold text-gray-600 font-mono whitespace-nowrap bg-gray-50 w-1/3">${key}</td>
|
|
53
|
+
<td class="py-2 px-3 text-xs text-gray-700 font-mono break-all">${value}</td>
|
|
54
|
+
</tr>
|
|
55
|
+
`).join('');
|
|
56
|
+
return `<table class="w-full border-collapse border border-gray-200 rounded hidden md:table">${rows}</table>`;
|
|
57
|
+
}
|
|
58
|
+
buildBodyView(body) {
|
|
59
|
+
if (!body)
|
|
60
|
+
return '<div class="text-gray-400 italic">No body content</div>';
|
|
61
|
+
const content = typeof body === 'object' ? JSON.stringify(body, null, 2) : body;
|
|
62
|
+
return `<pre class="bg-gray-900 text-gray-100 p-3 rounded text-xs font-mono overflow-x-auto whitespace-pre-wrap">${content}</pre>`;
|
|
63
|
+
}
|
|
64
|
+
buildExceptionView(exception) {
|
|
65
|
+
if (!exception)
|
|
66
|
+
return '';
|
|
67
|
+
return `
|
|
68
|
+
<div class="mb-6 bg-red-50 border border-red-200 rounded-lg overflow-hidden">
|
|
69
|
+
<div class="px-4 py-3 bg-red-100 border-b border-red-200 flex items-center">
|
|
70
|
+
<svg class="w-5 h-5 text-red-600 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path></svg>
|
|
71
|
+
<h3 class="font-bold text-red-800">Exception: ${exception.message}</h3>
|
|
72
|
+
</div>
|
|
73
|
+
<div class="p-4">
|
|
74
|
+
<pre class="text-xs text-red-700 font-mono whitespace-pre-wrap overflow-x-auto">${exception.stack}</pre>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
`;
|
|
78
|
+
}
|
|
79
|
+
buildTimingBar(timings, totalDuration) {
|
|
80
|
+
if (!timings)
|
|
81
|
+
return '';
|
|
82
|
+
const middlewarePct = (timings.middleware / timings.total) * 100;
|
|
83
|
+
const handlerPct = (timings.handler / timings.total) * 100;
|
|
84
|
+
return `
|
|
85
|
+
<div class="mt-6 mb-8">
|
|
86
|
+
<h3 class="text-sm font-semibold text-gray-700 mb-2">Execution Timing</h3>
|
|
87
|
+
<div class="h-4 bg-gray-100 rounded-full overflow-hidden flex w-full">
|
|
88
|
+
<div class="h-full bg-blue-200" style="width: ${middlewarePct}%" title="Middleware/Guards: ${timings.middleware.toFixed(2)}ms"></div>
|
|
89
|
+
<div class="h-full bg-indigo-500" style="width: ${handlerPct}%" title="Handler/Interceptor: ${timings.handler.toFixed(2)}ms"></div>
|
|
90
|
+
</div>
|
|
91
|
+
<div class="flex justify-between mt-2 text-xs text-gray-500">
|
|
92
|
+
<div class="flex items-center">
|
|
93
|
+
<span class="w-3 h-3 bg-blue-200 rounded-sm mr-1"></span>
|
|
94
|
+
Middleware: <strong>${timings.middleware.toFixed(2)}ms</strong>
|
|
95
|
+
</div>
|
|
96
|
+
<div class="flex items-center">
|
|
97
|
+
<span class="w-3 h-3 bg-indigo-500 rounded-sm mr-1"></span>
|
|
98
|
+
Handler: <strong>${timings.handler.toFixed(2)}ms</strong>
|
|
99
|
+
</div>
|
|
100
|
+
<div>
|
|
101
|
+
Total: <strong>${timings.total.toFixed(2)}ms</strong>
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
`;
|
|
106
|
+
}
|
|
107
|
+
buildQueriesList(queries) {
|
|
108
|
+
const rows = queries.map(q => this.viewService.render('partials/query_row', {
|
|
109
|
+
sql: q.sql,
|
|
110
|
+
duration: q.duration.toFixed(2),
|
|
111
|
+
requestId: q.requestId,
|
|
112
|
+
requestMethod: q.requestMethod,
|
|
113
|
+
requestUrl: q.requestUrl,
|
|
114
|
+
timeAgo: this.viewService.timeAgo(q.startTime)
|
|
115
|
+
})).join('') || '<tr><td colspan="3" class="p-8 text-center text-gray-500">No queries found.</td></tr>';
|
|
116
|
+
return this.viewService.render('queries', { rows });
|
|
117
|
+
}
|
|
118
|
+
buildLogsList(logs, currentPage, totalPages, totalLogs) {
|
|
119
|
+
const rows = logs.map(l => this.buildLogRow(l)).join('') ||
|
|
120
|
+
'<tr><td colspan="4" class="p-8 text-center text-gray-500">No logs captured.</td></tr>';
|
|
121
|
+
return this.viewService.render('logs', {
|
|
122
|
+
totalLogs,
|
|
123
|
+
rows,
|
|
124
|
+
pagination: this.buildPagination(currentPage, totalPages)
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
buildEntitiesList(entities) {
|
|
128
|
+
const rows = entities.map(e => this.viewService.render('partials/entity_row', {
|
|
129
|
+
name: e.name,
|
|
130
|
+
typeBadge: this.viewService.getDatabaseBadge(e.type),
|
|
131
|
+
database: e.database,
|
|
132
|
+
connection: e.connection,
|
|
133
|
+
tableName: e.tableName || '-',
|
|
134
|
+
columnsCount: e.columns?.length || 0,
|
|
135
|
+
columnsJson: JSON.stringify(e.columns || []),
|
|
136
|
+
rowId: `entity-${Math.random().toString(36).substr(2, 9)}`
|
|
137
|
+
})).join('');
|
|
138
|
+
const emptyState = !rows ? '<div class="p-8 text-center text-gray-500">No entities found.</div>' : '';
|
|
139
|
+
return this.viewService.render('entities', {
|
|
140
|
+
totalEntities: entities.length,
|
|
141
|
+
rows,
|
|
142
|
+
emptyState
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
buildNotFound(id) {
|
|
146
|
+
return this.viewService.render('not_found', { id });
|
|
147
|
+
}
|
|
148
|
+
buildRoutesList(routes) {
|
|
149
|
+
const rows = routes.map(r => this.viewService.render('partials/route_row', {
|
|
150
|
+
methodBadge: this.viewService.getMethodBadge(r.method),
|
|
151
|
+
method: r.method,
|
|
152
|
+
path: r.path,
|
|
153
|
+
controller: r.controller,
|
|
154
|
+
handler: r.handler
|
|
155
|
+
})).join('');
|
|
156
|
+
const emptyState = !rows ? '<div class="p-8 text-center text-gray-500">No routes found.</div>' : '';
|
|
157
|
+
return this.viewService.render('routes', {
|
|
158
|
+
totalRoutes: routes.length,
|
|
159
|
+
rows,
|
|
160
|
+
emptyState
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
buildCacheList(cacheOps) {
|
|
164
|
+
const rows = cacheOps.map(c => this.viewService.render('partials/cache_row', {
|
|
165
|
+
operationBadge: this.viewService.getCacheOperationBadge(c.operation),
|
|
166
|
+
key: c.key,
|
|
167
|
+
resultBadge: this.viewService.getCacheResultBadge(c.result),
|
|
168
|
+
store: c.store,
|
|
169
|
+
duration: c.duration.toFixed(2),
|
|
170
|
+
timeAgo: this.viewService.timeAgo(c.startTime)
|
|
171
|
+
})).join('');
|
|
172
|
+
const emptyState = !rows ? '<div class="p-8 text-center text-gray-500">No cache operations recorded.</div>' : '';
|
|
173
|
+
return this.viewService.render('cache', {
|
|
174
|
+
totalCacheOps: cacheOps.length,
|
|
175
|
+
rows,
|
|
176
|
+
emptyState
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
buildRequestRow(p) {
|
|
180
|
+
const statusCode = p.statusCode || 200;
|
|
181
|
+
return this.viewService.render('partials/request_row', {
|
|
182
|
+
methodBadge: this.viewService.getMethodBadge(p.method),
|
|
183
|
+
method: p.method,
|
|
184
|
+
id: p.id,
|
|
185
|
+
url: p.url,
|
|
186
|
+
statusClass: this.viewService.getStatusClass(statusCode),
|
|
187
|
+
statusCode: statusCode,
|
|
188
|
+
duration: p.duration,
|
|
189
|
+
queriesCount: p.queries.length > 0 ? `<span class="bg-gray-100 text-gray-700 px-2 py-0.5 rounded-full text-xs">${p.queries.length}</span>` : '<span class="text-gray-300">-</span>',
|
|
190
|
+
timeAgo: this.viewService.timeAgo(p.timestamp)
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
buildQueryDetail(q, index) {
|
|
194
|
+
return this.viewService.render('partials/detail_query_row', {
|
|
195
|
+
open: index < 3 ? 'open' : '',
|
|
196
|
+
index: index + 1,
|
|
197
|
+
dbBadge: this.viewService.getDatabaseBadge(q.database),
|
|
198
|
+
opBadge: q.operation ? `<span class="text-xs px-2 py-0.5 rounded bg-purple-100 text-purple-800 font-medium">${q.operation}</span>` : '',
|
|
199
|
+
connection: q.connection ? `<span class="text-xs px-2 py-0.5 rounded border border-gray-200 text-gray-500 bg-gray-50">${q.connection}</span>` : '',
|
|
200
|
+
durationClass: this.getDurationClass(q),
|
|
201
|
+
duration: q.duration.toFixed(2),
|
|
202
|
+
rowCount: q.rowCount ?? '-',
|
|
203
|
+
query: q.database === 'mongodb' && q.query ? q.query : q.sql,
|
|
204
|
+
tagsBadges: (q.tags || []).map((t) => this.getTagBadge(t)).join(''),
|
|
205
|
+
duplicationWarning: q.duplicatedCount > 1 ? `<div class="mt-1 text-xs text-orange-600 font-medium flex items-center"><svg class="w-3 h-3 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg> Executed ${q.duplicatedCount} times (N+1)</div>` : '',
|
|
206
|
+
planType: q.planType ? `<span class="ml-2 text-xs text-gray-400">(${q.planType})</span>` : '',
|
|
207
|
+
params: q.params && q.params.length ? `
|
|
208
|
+
<div class="mt-2 text-xs">
|
|
209
|
+
<span class="text-gray-500 font-semibold">Parameters:</span>
|
|
210
|
+
<code class="text-gray-700 bg-gray-100 px-1 py-0.5 rounded ml-1 font-mono">${JSON.stringify(q.params)}</code>
|
|
211
|
+
</div>
|
|
212
|
+
` : '',
|
|
213
|
+
filter: q.filter && q.database === 'mongodb' ? `
|
|
214
|
+
<div class="mt-2 text-xs">
|
|
215
|
+
<span class="text-gray-500 font-semibold">Filter:</span>
|
|
216
|
+
<pre class="text-gray-700 bg-gray-100 p-2 rounded mt-1 font-mono text-xs overflow-x-auto">${JSON.stringify(q.filter, null, 2)}</pre>
|
|
217
|
+
</div>
|
|
218
|
+
` : '',
|
|
219
|
+
explainPlan: q.explainPlan ? `
|
|
220
|
+
<div class="mt-3 border-t border-gray-100 pt-3">
|
|
221
|
+
<details class="group">
|
|
222
|
+
<summary class="text-xs font-medium text-indigo-600 cursor-pointer hover:text-indigo-800 select-none flex items-center">
|
|
223
|
+
<svg class="w-4 h-4 mr-1 transition-transform group-open:rotate-90" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"></path></svg>
|
|
224
|
+
View Explain Plan
|
|
225
|
+
</summary>
|
|
226
|
+
<pre class="mt-2 bg-gray-50 p-3 rounded text-xs text-gray-600 overflow-x-auto border border-gray-200">${JSON.stringify(q.explainPlan, null, 2)}</pre>
|
|
227
|
+
</details>
|
|
228
|
+
</div>
|
|
229
|
+
` : '',
|
|
230
|
+
error: q.error ? `
|
|
231
|
+
<div class="mt-3 bg-red-50 border-l-4 border-red-500 p-3 text-sm text-red-700">
|
|
232
|
+
<strong>Error:</strong> ${q.error}
|
|
233
|
+
</div>
|
|
234
|
+
` : ''
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
getTagBadge(tag) {
|
|
238
|
+
const styles = {
|
|
239
|
+
'slow': 'bg-yellow-100 text-yellow-800 border-yellow-200',
|
|
240
|
+
'n+1': 'bg-orange-100 text-orange-800 border-orange-200',
|
|
241
|
+
'seq-scan': 'bg-red-100 text-red-800 border-red-200'
|
|
242
|
+
};
|
|
243
|
+
const style = styles[tag] || 'bg-gray-100 text-gray-600 border-gray-200';
|
|
244
|
+
return `<span class="ml-2 text-xs px-2 py-0.5 rounded border ${style} font-medium tracking-wide uppercase shadow-sm" style="font-size: 0.65rem;">${tag}</span>`;
|
|
245
|
+
}
|
|
246
|
+
getDurationClass(q) {
|
|
247
|
+
if (q.error)
|
|
248
|
+
return 'text-red-700 bg-red-50';
|
|
249
|
+
if (q.duration > 100)
|
|
250
|
+
return 'text-yellow-700 bg-yellow-50 font-bold';
|
|
251
|
+
return 'text-gray-600 bg-gray-100';
|
|
252
|
+
}
|
|
253
|
+
buildMetadataSidebar(p) {
|
|
254
|
+
return this.viewService.render('partials/metadata_sidebar', {
|
|
255
|
+
statusColor: (p.statusCode || 200) >= 400 ? 'text-red-600' : 'text-green-600',
|
|
256
|
+
statusCode: p.statusCode || 200,
|
|
257
|
+
duration: p.duration,
|
|
258
|
+
memory: p.memory ? Math.round(p.memory.rss / 1024 / 1024) + ' MB' : '-',
|
|
259
|
+
controller: p.controller || '-',
|
|
260
|
+
handler: p.handler || '-'
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
buildLogRow(l) {
|
|
264
|
+
return this.viewService.render('partials/log_row', {
|
|
265
|
+
levelColor: this.viewService.getLogLevelColor(l.level),
|
|
266
|
+
level: l.level,
|
|
267
|
+
message: l.message,
|
|
268
|
+
context: l.context ? `<span class="ml-2 text-xs text-gray-500">[${l.context}]</span>` : '',
|
|
269
|
+
requestId: l.requestId,
|
|
270
|
+
requestMethod: l.requestMethod,
|
|
271
|
+
requestUrl: l.requestUrl,
|
|
272
|
+
timeAgo: this.viewService.timeAgo(l.timestamp)
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
buildPagination(currentPage, totalPages) {
|
|
276
|
+
if (totalPages <= 1)
|
|
277
|
+
return '';
|
|
278
|
+
return this.viewService.render('partials/pagination', {
|
|
279
|
+
currentPage,
|
|
280
|
+
totalPages,
|
|
281
|
+
previousPage: currentPage > 1 ? `
|
|
282
|
+
<a href="/__profiler/view/logs?page=${currentPage - 1}" class="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50">
|
|
283
|
+
Previous
|
|
284
|
+
</a>
|
|
285
|
+
` : `
|
|
286
|
+
<span class="px-3 py-1 border border-gray-200 rounded-md text-sm font-medium text-gray-400 bg-gray-50 cursor-not-allowed">
|
|
287
|
+
Previous
|
|
288
|
+
</span>
|
|
289
|
+
`,
|
|
290
|
+
nextPage: currentPage < totalPages ? `
|
|
291
|
+
<a href="/__profiler/view/logs?page=${currentPage + 1}" class="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50">
|
|
292
|
+
Next
|
|
293
|
+
</a>
|
|
294
|
+
` : `
|
|
295
|
+
<span class="px-3 py-1 border border-gray-200 rounded-md text-sm font-medium text-gray-400 bg-gray-50 cursor-not-allowed">
|
|
296
|
+
Next
|
|
297
|
+
</span>
|
|
298
|
+
`
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
getStatusColor(statusCode) {
|
|
302
|
+
if (statusCode >= 500)
|
|
303
|
+
return 'bg-red-500';
|
|
304
|
+
if (statusCode >= 400)
|
|
305
|
+
return 'bg-yellow-500';
|
|
306
|
+
if (statusCode >= 300)
|
|
307
|
+
return 'bg-blue-500';
|
|
308
|
+
return 'bg-green-500';
|
|
309
|
+
}
|
|
310
|
+
buildCacheSection(cache) {
|
|
311
|
+
if (!cache || cache.length === 0)
|
|
312
|
+
return '';
|
|
313
|
+
const rows = cache.map(c => this.viewService.render('partials/cache_row', {
|
|
314
|
+
operationBadge: this.viewService.getCacheOperationBadge(c.operation),
|
|
315
|
+
key: c.key,
|
|
316
|
+
resultBadge: this.viewService.getCacheResultBadge(c.result),
|
|
317
|
+
store: c.store,
|
|
318
|
+
duration: c.duration.toFixed(2),
|
|
319
|
+
timeAgo: this.viewService.timeAgo(c.startTime)
|
|
320
|
+
})).join('');
|
|
321
|
+
return `
|
|
322
|
+
<div class="bg-gray-50 rounded-lg border border-gray-200 p-4 mb-4">
|
|
323
|
+
<h2 class="text-sm font-bold text-gray-500 uppercase tracking-widest mb-4">Cache Operations (${cache.length})</h2>
|
|
324
|
+
<div class="bg-white rounded shadow-sm border border-gray-200 overflow-hidden">
|
|
325
|
+
<table class="min-w-full divide-y divide-gray-200">
|
|
326
|
+
<thead class="bg-gray-50">
|
|
327
|
+
<tr>
|
|
328
|
+
<th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">Op</th>
|
|
329
|
+
<th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">Key</th>
|
|
330
|
+
<th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">Result</th>
|
|
331
|
+
<th class="px-4 py-2 text-right text-xs font-medium text-gray-500 uppercase">Duration</th>
|
|
332
|
+
</tr>
|
|
333
|
+
</thead>
|
|
334
|
+
<tbody class="divide-y divide-gray-200">
|
|
335
|
+
${rows}
|
|
336
|
+
</tbody>
|
|
337
|
+
</table>
|
|
338
|
+
</div>
|
|
339
|
+
</div>
|
|
340
|
+
`;
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
exports.TemplateBuilderService = TemplateBuilderService;
|
|
344
|
+
exports.TemplateBuilderService = TemplateBuilderService = __decorate([
|
|
345
|
+
(0, common_1.Injectable)(),
|
|
346
|
+
__metadata("design:paramtypes", [view_service_1.ViewService])
|
|
347
|
+
], TemplateBuilderService);
|
|
348
|
+
//# sourceMappingURL=template-builder.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-builder.service.js","sourceRoot":"","sources":["../../../libs/nestjs-profiler/src/services/template-builder.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAE5C,iDAA6C;AAGtC,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAC/B,YAA6B,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAI,CAAC;IAK1D,cAAc,CAAC,QAA0B;QACrC,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACjE,MAAM,UAAU,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,4EAA4E,CAAC,CAAC,CAAC,EAAE,CAAC;QAE7G,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,WAAW,EAAE;YACxC,IAAI;YACJ,UAAU;SACb,CAAC,CAAC;IACP,CAAC;IAKD,WAAW,CAAC,OAAuB;QAC/B,MAAM,OAAO,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AE,OAAO,eAAe,CAAC;QAC9C,IAAI,UAAU,IAAI,GAAG;YAAE,OAAO,aAAa,CAAC;QAC5C,OAAO,cAAc,CAAC;IAC1B,CAAC;IAEO,iBAAiB,CAAC,KAAY;QAClC,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;QAE5C,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,oBAAoB,EAAE;YACtE,cAAc,EAAE,IAAI,CAAC,WAAW,CAAC,sBAAsB,CAAC,CAAC,CAAC,SAAS,CAAC;YACpE,GAAG,EAAE,CAAC,CAAC,GAAG;YACV,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC,CAAC,MAAM,CAAC;YAC3D,KAAK,EAAE,CAAC,CAAC,KAAK;YACd,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;YAC/B,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;SACjD,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEb,OAAO;;+GAEgG,KAAK,CAAC,MAAM;;;;;;;;;;;;8BAY7F,IAAI;;;;;SAKzB,CAAC;IACN,CAAC;CACJ,CAAA;AA/XY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,mBAAU,GAAE;qCAEiC,0BAAW;GAD5C,sBAAsB,CA+XlC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare class ViewService {
|
|
2
|
+
private readonly viewsPath;
|
|
3
|
+
constructor();
|
|
4
|
+
exists(viewName: string): boolean;
|
|
5
|
+
render(viewName: string, data?: any): string;
|
|
6
|
+
renderWithLayout(title: string, content: string, activeTab?: string): string;
|
|
7
|
+
private loadTemplate;
|
|
8
|
+
private interpolate;
|
|
9
|
+
private escapeHtml;
|
|
10
|
+
timeAgo(timestamp: number): string;
|
|
11
|
+
getStatusClass(statusCode: number): string;
|
|
12
|
+
getMethodBadge(method: string): string;
|
|
13
|
+
getDatabaseBadge(database: string): string;
|
|
14
|
+
getLogLevelColor(level: string): string;
|
|
15
|
+
getCacheOperationBadge(op: string): string;
|
|
16
|
+
getCacheResultBadge(result: string): string;
|
|
17
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
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;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.ViewService = void 0;
|
|
46
|
+
const common_1 = require("@nestjs/common");
|
|
47
|
+
const fs = __importStar(require("fs"));
|
|
48
|
+
const path = __importStar(require("path"));
|
|
49
|
+
let ViewService = class ViewService {
|
|
50
|
+
constructor() {
|
|
51
|
+
this.viewsPath = path.join(__dirname, '..', 'views');
|
|
52
|
+
}
|
|
53
|
+
exists(viewName) {
|
|
54
|
+
const viewPath = path.join(this.viewsPath, `${viewName}.html`);
|
|
55
|
+
return fs.existsSync(viewPath);
|
|
56
|
+
}
|
|
57
|
+
render(viewName, data = {}) {
|
|
58
|
+
const viewPath = path.join(this.viewsPath, `${viewName}.html`);
|
|
59
|
+
let template = this.loadTemplate(viewPath);
|
|
60
|
+
template = this.interpolate(template, data);
|
|
61
|
+
return template;
|
|
62
|
+
}
|
|
63
|
+
renderWithLayout(title, content, activeTab = 'requests') {
|
|
64
|
+
const layoutPath = path.join(this.viewsPath, 'layout.html');
|
|
65
|
+
let layout = this.loadTemplate(layoutPath);
|
|
66
|
+
const data = {
|
|
67
|
+
title,
|
|
68
|
+
content,
|
|
69
|
+
activeTab,
|
|
70
|
+
activeClass: 'bg-indigo-600 text-white',
|
|
71
|
+
inactiveClass: 'text-slate-300 hover:bg-slate-800 hover:text-white',
|
|
72
|
+
requestsActive: activeTab === 'requests' ? 'bg-indigo-600 text-white' : 'text-slate-300 hover:bg-slate-800 hover:text-white',
|
|
73
|
+
queriesActive: activeTab === 'queries' ? 'bg-indigo-600 text-white' : 'text-slate-300 hover:bg-slate-800 hover:text-white',
|
|
74
|
+
logsActive: activeTab === 'logs' ? 'bg-indigo-600 text-white' : 'text-slate-300 hover:bg-slate-800 hover:text-white',
|
|
75
|
+
entitiesActive: activeTab === 'entities' ? 'bg-indigo-600 text-white' : 'text-slate-300 hover:bg-slate-800 hover:text-white',
|
|
76
|
+
routesActive: activeTab === 'routes' ? 'bg-indigo-600 text-white' : 'text-slate-300 hover:bg-slate-800 hover:text-white',
|
|
77
|
+
cacheActive: activeTab === 'cache' ? 'bg-indigo-600 text-white' : 'text-slate-300 hover:bg-slate-800 hover:text-white',
|
|
78
|
+
requestsIconClass: activeTab === 'requests' ? 'text-indigo-300' : 'text-slate-400 group-hover:text-white',
|
|
79
|
+
queriesIconClass: activeTab === 'queries' ? 'text-indigo-300' : 'text-slate-400 group-hover:text-white',
|
|
80
|
+
logsIconClass: activeTab === 'logs' ? 'text-indigo-300' : 'text-slate-400 group-hover:text-white',
|
|
81
|
+
entitiesIconClass: activeTab === 'entities' ? 'text-indigo-300' : 'text-slate-400 group-hover:text-white',
|
|
82
|
+
routesIconClass: activeTab === 'routes' ? 'text-indigo-300' : 'text-slate-400 group-hover:text-white',
|
|
83
|
+
cacheIconClass: activeTab === 'cache' ? 'text-indigo-300' : 'text-slate-400 group-hover:text-white',
|
|
84
|
+
};
|
|
85
|
+
layout = this.interpolate(layout, data);
|
|
86
|
+
return layout;
|
|
87
|
+
}
|
|
88
|
+
loadTemplate(filePath) {
|
|
89
|
+
try {
|
|
90
|
+
return fs.readFileSync(filePath, 'utf-8');
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
throw new Error(`Failed to load template: ${filePath}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
interpolate(template, data) {
|
|
97
|
+
template = template.replace(/\{\{\{\s*(\w+)\s*\}\}\}/g, (match, key) => {
|
|
98
|
+
return data[key] ?? '';
|
|
99
|
+
});
|
|
100
|
+
template = template.replace(/\{\{\s*(\w+)\s*\}\}/g, (match, key) => {
|
|
101
|
+
return this.escapeHtml(data[key] ?? '');
|
|
102
|
+
});
|
|
103
|
+
return template;
|
|
104
|
+
}
|
|
105
|
+
escapeHtml(text) {
|
|
106
|
+
const map = {
|
|
107
|
+
'&': '&',
|
|
108
|
+
'<': '<',
|
|
109
|
+
'>': '>',
|
|
110
|
+
'"': '"',
|
|
111
|
+
"'": '''
|
|
112
|
+
};
|
|
113
|
+
return String(text).replace(/[&<>"']/g, (m) => map[m]);
|
|
114
|
+
}
|
|
115
|
+
timeAgo(timestamp) {
|
|
116
|
+
const seconds = Math.floor((Date.now() - timestamp) / 1000);
|
|
117
|
+
let interval = seconds / 31536000;
|
|
118
|
+
if (interval > 1)
|
|
119
|
+
return Math.floor(interval) + "y ago";
|
|
120
|
+
interval = seconds / 2592000;
|
|
121
|
+
if (interval > 1)
|
|
122
|
+
return Math.floor(interval) + "mo ago";
|
|
123
|
+
interval = seconds / 86400;
|
|
124
|
+
if (interval > 1)
|
|
125
|
+
return Math.floor(interval) + "d ago";
|
|
126
|
+
interval = seconds / 3600;
|
|
127
|
+
if (interval > 1)
|
|
128
|
+
return Math.floor(interval) + "h ago";
|
|
129
|
+
interval = seconds / 60;
|
|
130
|
+
if (interval > 1)
|
|
131
|
+
return Math.floor(interval) + "m ago";
|
|
132
|
+
return Math.floor(seconds) + "s ago";
|
|
133
|
+
}
|
|
134
|
+
getStatusClass(statusCode) {
|
|
135
|
+
if (statusCode >= 500)
|
|
136
|
+
return 'bg-red-100 text-red-700';
|
|
137
|
+
if (statusCode >= 400)
|
|
138
|
+
return 'bg-yellow-100 text-yellow-700';
|
|
139
|
+
if (statusCode >= 300)
|
|
140
|
+
return 'bg-blue-100 text-blue-700';
|
|
141
|
+
return 'bg-green-100 text-green-700';
|
|
142
|
+
}
|
|
143
|
+
getMethodBadge(method) {
|
|
144
|
+
const badges = {
|
|
145
|
+
'GET': 'bg-blue-100 text-blue-800',
|
|
146
|
+
'POST': 'bg-green-100 text-green-800',
|
|
147
|
+
'PUT': 'bg-orange-100 text-orange-800',
|
|
148
|
+
'PATCH': 'bg-yellow-100 text-yellow-800',
|
|
149
|
+
'DELETE': 'bg-red-100 text-red-800',
|
|
150
|
+
};
|
|
151
|
+
const classes = badges[method] || 'bg-gray-100 text-gray-800';
|
|
152
|
+
return `<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full ${classes}">${method}</span>`;
|
|
153
|
+
}
|
|
154
|
+
getDatabaseBadge(database) {
|
|
155
|
+
if (database === 'mongodb') {
|
|
156
|
+
return '<span class="text-xs px-2 py-0.5 rounded bg-green-100 text-green-800 font-medium">MongoDB</span>';
|
|
157
|
+
}
|
|
158
|
+
if (database === 'mysql') {
|
|
159
|
+
return '<span class="text-xs px-2 py-0.5 rounded bg-orange-100 text-orange-800 font-medium">MySQL</span>';
|
|
160
|
+
}
|
|
161
|
+
return '<span class="text-xs px-2 py-0.5 rounded bg-blue-100 text-blue-800 font-medium">PostgreSQL</span>';
|
|
162
|
+
}
|
|
163
|
+
getLogLevelColor(level) {
|
|
164
|
+
if (level === 'error')
|
|
165
|
+
return 'text-red-700 bg-red-50 ring-red-600/20';
|
|
166
|
+
if (level === 'warn')
|
|
167
|
+
return 'text-yellow-800 bg-yellow-50 ring-yellow-600/20';
|
|
168
|
+
return 'text-gray-600 bg-gray-50 ring-gray-500/10';
|
|
169
|
+
}
|
|
170
|
+
getCacheOperationBadge(op) {
|
|
171
|
+
const badges = {
|
|
172
|
+
'get': 'bg-blue-100 text-blue-800',
|
|
173
|
+
'set': 'bg-purple-100 text-purple-800',
|
|
174
|
+
'del': 'bg-red-100 text-red-800',
|
|
175
|
+
'reset': 'bg-orange-100 text-orange-800',
|
|
176
|
+
};
|
|
177
|
+
const classes = badges[op] || 'bg-gray-100 text-gray-800';
|
|
178
|
+
return `<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full uppercase ${classes}">${op}</span>`;
|
|
179
|
+
}
|
|
180
|
+
getCacheResultBadge(result) {
|
|
181
|
+
const badges = {
|
|
182
|
+
'hit': 'bg-green-100 text-green-800',
|
|
183
|
+
'miss': 'bg-red-100 text-red-800',
|
|
184
|
+
'success': 'bg-green-100 text-green-800',
|
|
185
|
+
'fail': 'bg-red-100 text-red-800',
|
|
186
|
+
};
|
|
187
|
+
const classes = badges[result] || 'bg-gray-100 text-gray-800';
|
|
188
|
+
return `<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full uppercase ${classes}">${result}</span>`;
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
exports.ViewService = ViewService;
|
|
192
|
+
exports.ViewService = ViewService = __decorate([
|
|
193
|
+
(0, common_1.Injectable)(),
|
|
194
|
+
__metadata("design:paramtypes", [])
|
|
195
|
+
], ViewService);
|
|
196
|
+
//# sourceMappingURL=view.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view.service.js","sourceRoot":"","sources":["../../../libs/nestjs-profiler/src/services/view.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,uCAAyB;AACzB,2CAA6B;AAGtB,IAAM,WAAW,GAAjB,MAAM,WAAW;IAGpB;QAGI,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,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E,IAAI,KAAK,KAAK,MAAM;YAAE,OAAO,iDAAiD,CAAC;QAC/E,OAAO,2CAA2C,CAAC;IACvD,CAAC;IAKD,sBAAsB,CAAC,EAAU;QAC7B,MAAM,MAAM,GAA2B;YACnC,KAAK,EAAE,2BAA2B;YAClC,KAAK,EAAE,+BAA+B;YACtC,KAAK,EAAE,yBAAyB;YAChC,OAAO,EAAE,+BAA+B;SAC3C,CAAC;QACF,MAAM,OAAO,GAAG,MAAM,CAAC,EAAE,CAAC,IAAI,2BAA2B,CAAC;QAC1D,OAAO,wFAAwF,OAAO,KAAK,EAAE,SAAS,CAAC;IAC3H,CAAC;IAKD,mBAAmB,CAAC,MAAc;QAC9B,MAAM,MAAM,GAA2B;YACnC,KAAK,EAAE,6BAA6B;YACpC,MAAM,EAAE,yBAAyB;YACjC,SAAS,EAAE,6BAA6B;YACxC,MAAM,EAAE,yBAAyB;SACpC,CAAC;QACF,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,2BAA2B,CAAC;QAC9D,OAAO,wFAAwF,OAAO,KAAK,MAAM,SAAS,CAAC;IAC/H,CAAC;CACJ,CAAA;AAzMY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;;GACA,WAAW,CAyMvB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RequestProfile } from '../common/profiler.model';
|
|
2
|
+
import { ProfilerStorage } from './profiler-storage.interface';
|
|
3
|
+
export declare class InMemoryProfilerStorage implements ProfilerStorage {
|
|
4
|
+
private profiles;
|
|
5
|
+
private limit;
|
|
6
|
+
save(profile: RequestProfile): Promise<void>;
|
|
7
|
+
get(id: string): Promise<RequestProfile | null>;
|
|
8
|
+
all(): Promise<RequestProfile[]>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InMemoryProfilerStorage = void 0;
|
|
4
|
+
class InMemoryProfilerStorage {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.profiles = [];
|
|
7
|
+
this.limit = 100;
|
|
8
|
+
}
|
|
9
|
+
async save(profile) {
|
|
10
|
+
const existingIndex = this.profiles.findIndex(p => p.id === profile.id);
|
|
11
|
+
if (existingIndex !== -1) {
|
|
12
|
+
this.profiles[existingIndex] = profile;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
this.profiles.unshift(profile);
|
|
16
|
+
if (this.profiles.length > this.limit) {
|
|
17
|
+
this.profiles.pop();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
async get(id) {
|
|
22
|
+
return this.profiles.find((p) => p.id === id) || null;
|
|
23
|
+
}
|
|
24
|
+
async all() {
|
|
25
|
+
return this.profiles;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.InMemoryProfilerStorage = InMemoryProfilerStorage;
|
|
29
|
+
//# sourceMappingURL=in-memory-profiler-storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-memory-profiler-storage.js","sourceRoot":"","sources":["../../../libs/nestjs-profiler/src/storage/in-memory-profiler-storage.ts"],"names":[],"mappings":";;;AAGA,MAAa,uBAAuB;IAApC;QACY,aAAQ,GAAqB,EAAE,CAAC;QAChC,UAAK,GAAG,GAAG,CAAC;IAqBxB,CAAC;IAnBG,KAAK,CAAC,IAAI,CAAC,OAAuB;QAC9B,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,OAAO,CAAC,EAAE,CAAC,CAAC;QACxE,IAAI,aAAa,KAAK,CAAC,CAAC,EAAE,CAAC;YACvB,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,GAAG,OAAO,CAAC;QAC3C,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YAC/B,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;gBACpC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;YACxB,CAAC;QACL,CAAC;IACL,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,EAAU;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,IAAI,CAAC;IAC1D,CAAC;IAED,KAAK,CAAC,GAAG;QACL,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;CACJ;AAvBD,0DAuBC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { RequestProfile } from '../common/profiler.model';
|
|
2
|
+
export interface ProfilerStorage {
|
|
3
|
+
save(profile: RequestProfile): Promise<void> | void;
|
|
4
|
+
get(id: string): Promise<RequestProfile | null> | RequestProfile | null;
|
|
5
|
+
all(): Promise<RequestProfile[]> | RequestProfile[];
|
|
6
|
+
}
|