5htp-core 0.6.2-4 → 0.6.2-6
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/client/app/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "5htp-core",
|
|
3
3
|
"description": "Convenient TypeScript framework designed for Performance and Productivity.",
|
|
4
|
-
"version": "0.6.2-
|
|
4
|
+
"version": "0.6.2-6",
|
|
5
5
|
"author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
|
|
6
6
|
"repository": "git://github.com/gaetanlegac/5htp-core.git",
|
|
7
7
|
"license": "MIT",
|
|
@@ -301,45 +301,10 @@ export default class Console {
|
|
|
301
301
|
// On envoi l'email avant l'insertion dans bla bdd
|
|
302
302
|
// Car cette denrière a plus de chances de provoquer une erreur
|
|
303
303
|
//const logs = this.logs.filter(e => e.channel.channelId === channelId).slice(-100);
|
|
304
|
-
const
|
|
305
|
-
const context: object[] = [];
|
|
306
|
-
|
|
307
|
-
let currentError: TCatchedError | undefined = error;
|
|
308
|
-
let title: string | undefined;
|
|
309
|
-
while (currentError !== undefined) {
|
|
310
|
-
|
|
311
|
-
if (title === undefined)
|
|
312
|
-
title = currentError.message;
|
|
313
|
-
|
|
314
|
-
// Stacktrace
|
|
315
|
-
this.logger.error(LogPrefix, `Sending bug report for the following error:`, currentError);
|
|
316
|
-
stacktraces.push(currentError.stack || currentError.message);
|
|
317
|
-
|
|
318
|
-
// Context
|
|
319
|
-
if (('dataForDebugging' in currentError) && currentError.dataForDebugging !== undefined) {
|
|
320
|
-
console.error(LogPrefix, `More data about the error:`, currentError.dataForDebugging);
|
|
321
|
-
context.push(currentError.dataForDebugging || {});
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
// Print the error so it's accessible via logs
|
|
325
|
-
if (currentError instanceof SqlError) {
|
|
326
|
-
let printedQuery: string;
|
|
327
|
-
try {
|
|
328
|
-
printedQuery = this.printSql( currentError.query );
|
|
329
|
-
} catch (error) {
|
|
330
|
-
printedQuery = 'Failed to print query:' + (error || 'unknown error');
|
|
331
|
-
}
|
|
332
|
-
console.error(`Error caused by this query:`, printedQuery);
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
// Go deeper
|
|
336
|
-
currentError = 'originalError' in currentError
|
|
337
|
-
? currentError.originalError
|
|
338
|
-
: undefined
|
|
339
|
-
}
|
|
304
|
+
const inspection = this.getDetailledError(error);
|
|
340
305
|
|
|
341
306
|
// Genertae unique error hash
|
|
342
|
-
const hash = md5( stacktraces[0] );
|
|
307
|
+
const hash = md5( inspection.stacktraces[0] );
|
|
343
308
|
|
|
344
309
|
// Don't send the same error twice in a row (avoid email spamming)
|
|
345
310
|
const lastReport = this.reported[hash];
|
|
@@ -390,12 +355,56 @@ export default class Console {
|
|
|
390
355
|
} : {}),
|
|
391
356
|
|
|
392
357
|
// Error
|
|
393
|
-
title,
|
|
394
|
-
stacktraces,
|
|
395
|
-
context
|
|
358
|
+
title: inspection.title,
|
|
359
|
+
stacktraces: inspection.stacktraces,
|
|
360
|
+
context: inspection.context
|
|
396
361
|
}
|
|
397
362
|
|
|
398
363
|
await application.runHook('bug', bugReport);
|
|
364
|
+
|
|
365
|
+
return bugReport;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
public getDetailledError( error: TCatchedError ) {
|
|
369
|
+
|
|
370
|
+
const stacktraces: string[] = [];
|
|
371
|
+
const context: object[] = [];
|
|
372
|
+
|
|
373
|
+
let currentError: TCatchedError | undefined = error;
|
|
374
|
+
let title: string | undefined;
|
|
375
|
+
while (currentError !== undefined) {
|
|
376
|
+
|
|
377
|
+
if (title === undefined)
|
|
378
|
+
title = currentError.message;
|
|
379
|
+
|
|
380
|
+
// Stacktrace
|
|
381
|
+
this.logger.error(LogPrefix, `Sending bug report for the following error:`, currentError);
|
|
382
|
+
stacktraces.push(currentError.stack || currentError.message);
|
|
383
|
+
|
|
384
|
+
// Context
|
|
385
|
+
if (('dataForDebugging' in currentError) && currentError.dataForDebugging !== undefined) {
|
|
386
|
+
console.error(LogPrefix, `More data about the error:`, currentError.dataForDebugging);
|
|
387
|
+
context.push(currentError.dataForDebugging || {});
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// Print the error so it's accessible via logs
|
|
391
|
+
if (currentError instanceof SqlError) {
|
|
392
|
+
let printedQuery: string;
|
|
393
|
+
try {
|
|
394
|
+
printedQuery = this.printSql( currentError.query );
|
|
395
|
+
} catch (error) {
|
|
396
|
+
printedQuery = 'Failed to print query:' + (error || 'unknown error');
|
|
397
|
+
}
|
|
398
|
+
console.error(`Error caused by this query:`, printedQuery);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// Go deeper
|
|
402
|
+
currentError = 'originalError' in currentError
|
|
403
|
+
? currentError.originalError
|
|
404
|
+
: undefined
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
return { title, stacktraces, context };
|
|
399
408
|
}
|
|
400
409
|
|
|
401
410
|
public getChannel() {
|
|
@@ -416,11 +425,7 @@ export default class Console {
|
|
|
416
425
|
<b>User</b>: ${report.user ? (report.user.name + ' (' + report.user.email + ')') : 'Unknown'}<br />
|
|
417
426
|
<b>IP</b>: ${report.ip}<br />
|
|
418
427
|
|
|
419
|
-
${report.stacktraces
|
|
420
|
-
<hr />
|
|
421
|
-
<b>Error ${index + 1}</b>:
|
|
422
|
-
${this.printHtml(stacktrace)}<br />
|
|
423
|
-
`).join('')}
|
|
428
|
+
${this.stacktracesToHTML(report.stacktraces)}
|
|
424
429
|
|
|
425
430
|
${report.context.map((context, index) => `
|
|
426
431
|
<hr />
|
|
@@ -439,6 +444,13 @@ ${report.request ? `
|
|
|
439
444
|
Logs: ${this.config.enable ? `<br/>` + this.logsToHTML(report.logs) : 'Logs collection is disabled'}<br />
|
|
440
445
|
`
|
|
441
446
|
}
|
|
447
|
+
|
|
448
|
+
public stacktracesToHTML( stacktraces: string[] ): string {
|
|
449
|
+
return stacktraces.map((stacktrace, index) => `
|
|
450
|
+
<hr />
|
|
451
|
+
<b>Stacktrace ${index + 1}</b>: ${this.printHtml(stacktrace)}<br />
|
|
452
|
+
`).join('');
|
|
453
|
+
}
|
|
442
454
|
|
|
443
455
|
public logsToHTML( logs: TJsonLog[] ): string {
|
|
444
456
|
|
package/server/app/index.ts
CHANGED
|
@@ -144,13 +144,16 @@ export default abstract class Service<
|
|
|
144
144
|
public use<TService extends AnyService = AnyService>(
|
|
145
145
|
serviceId: string,
|
|
146
146
|
useOptions: { optional?: boolean } = {}
|
|
147
|
-
): TService {
|
|
147
|
+
): TService | undefined {
|
|
148
148
|
|
|
149
149
|
const registeredService = this.app.registered[serviceId];
|
|
150
|
-
if (registeredService
|
|
150
|
+
if (registeredService !== undefined)
|
|
151
|
+
return this.app[ registeredService.name ];
|
|
152
|
+
|
|
153
|
+
if (useOptions.optional === false)
|
|
151
154
|
throw new Error(`Service ${registeredService} not registered.`);
|
|
152
155
|
|
|
153
|
-
return
|
|
156
|
+
return undefined;
|
|
154
157
|
}
|
|
155
158
|
|
|
156
159
|
/*----------------------------------
|
|
@@ -137,8 +137,8 @@ export default class DocumentRenderer<TRouter extends Router> {
|
|
|
137
137
|
|
|
138
138
|
private async scripts( response: ServerResponse<TRouter>, page: Page ) {
|
|
139
139
|
|
|
140
|
-
const
|
|
141
|
-
|
|
140
|
+
const ssrData = response.forSsr(page);
|
|
141
|
+
const context = safeStringify( ssrData );
|
|
142
142
|
const routesForClient = JSON.stringify( this.router.ssrRoutes );
|
|
143
143
|
|
|
144
144
|
return <>
|
package/types/icons.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type TIcones = "
|
|
1
|
+
export type TIcones = "solid/spinner-third"|"times"|"brands/whatsapp"|"info-circle"|"check-circle"|"exclamation-circle"|"times-circle"|"search"|"check"|"angle-down"|"arrow-left"|"arrow-right"|"meh-rolling-eyes"|"eye"|"trash"|"link"|"file"|"unlink"|"pen"|"bold"|"italic"|"underline"|"strikethrough"|"subscript"|"superscript"|"code"|"plus"|"font"|"empty-set"|"plus-circle"|"horizontal-rule"|"page-break"|"image"|"table"|"poll"|"columns"|"sticky-note"|"caret-right"|"align-left"|"align-center"|"align-right"|"align-justify"|"indent"|"outdent"|"list-ul"|"check-square"|"h1"|"h2"|"h3"|"h4"|"list-ol"|"paragraph"|"quote-left"
|