5htp-core 0.2.6-9 → 0.2.7-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/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.2.6-9",
4
+ "version": "0.2.7-1",
5
5
  "author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
6
6
  "repository": "git://github.com/gaetanlegac/5htp-core.git",
7
7
  "license": "MIT",
@@ -51,6 +51,8 @@ type AppIdentityConfig = {
51
51
 
52
52
  web: {
53
53
  title: string,
54
+ titleSuffix: string,
55
+ fullTitle: string,
54
56
  description: string,
55
57
  version: string
56
58
  }
@@ -190,10 +190,10 @@ export default class Console extends Service<Config, Hooks, Application> {
190
190
  }
191
191
 
192
192
  private clean() {
193
- this.config.debug && console.log(LogPrefix, `Clean logs buffer. Current size:`, this.logs.length, '/', this.config.bufferLimit);
193
+ /*this.config.debug && console.log(LogPrefix, `Clean logs buffer. Current size:`, this.logs.length, '/', this.config.bufferLimit);
194
194
  const bufferOverflow = this.logs.length - this.config.bufferLimit;
195
195
  if (bufferOverflow > 0)
196
- this.logs = this.logs.slice(bufferOverflow);
196
+ this.logs = this.logs.slice(bufferOverflow);*/
197
197
  }
198
198
 
199
199
  /*----------------------------------
@@ -230,7 +230,7 @@ export default class Console extends Service<Config, Hooks, Application> {
230
230
  // On envoi l'email avant l'insertion dans bla bdd
231
231
  // Car cette denrière a plus de chances de provoquer une erreur
232
232
  const logsHtml = this.printHtml(
233
- this.logs.filter(e => e.channelId === channelId),
233
+ this.logs/*.filter(e => e.channelId === channelId)*/.slice(-100),
234
234
  true
235
235
  );
236
236
 
@@ -372,7 +372,7 @@ export default class Console extends Service<Config, Hooks, Application> {
372
372
  }
373
373
  }
374
374
 
375
- return this.printHtml( entries.reverse() );
375
+ return this.printHtml( entries );
376
376
  }
377
377
 
378
378
  public printHtml(logs: TLog[], full: boolean = false): string {
@@ -282,7 +282,7 @@ export default class ServerRouter<
282
282
  //await TrackingService.LoadCache();
283
283
 
284
284
  // Generate typescript typings
285
- if (this.app.env.profile = 'dev')
285
+ if (this.app.env.profile === 'dev')
286
286
  this.genTypings();
287
287
 
288
288
  // Ordonne par ordre de priorité
@@ -550,11 +550,12 @@ declare type Routes = {
550
550
  // Rapport / debug
551
551
  if (code === 500) {
552
552
 
553
+ // Print the error here so the stacktrace appears in the bug report logs
554
+ console.log(LogPrefix, "Error catched from the router:", e);
555
+
553
556
  // Report error
554
557
  await this.app.runHook('error', e, request);
555
558
 
556
- console.log("ERROR 500 VIA ROUTER", e);
557
-
558
559
  // Don't exose technical errors to users
559
560
  if (this.app.env.profile === 'prod')
560
561
  e.message = "We encountered an internal error, and our team has just been notified. Sorry for the inconvenience.";
@@ -22,6 +22,11 @@ const chunks = require('./chunk-manifest.json');
22
22
  - TYPES
23
23
  ----------------------------------*/
24
24
 
25
+ const seoLimits = {
26
+ title: 70,
27
+ description: 255
28
+ }
29
+
25
30
  /*----------------------------------
26
31
  - FONCTION
27
32
  ----------------------------------*/
@@ -35,7 +40,8 @@ export default class Page<TRouter extends Router = Router> extends PageResponse<
35
40
  public layout?: Layout,
36
41
 
37
42
  public route = context.route,
38
- public router = context.request.router
43
+ public app = context.app,
44
+ public router = context.request.router,
39
45
 
40
46
  ) {
41
47
 
@@ -45,6 +51,16 @@ export default class Page<TRouter extends Router = Router> extends PageResponse<
45
51
 
46
52
  public render(): Promise<string> {
47
53
 
54
+ // Complete SEO metadatas
55
+ const titleSuffix = ' | ' + this.app.identity.web.titleSuffix
56
+ if (this.title === undefined)
57
+ this.title = this.app.identity.web.fullTitle;
58
+ else if (this.title.length < seoLimits.title - titleSuffix.length)
59
+ this.title += titleSuffix;
60
+
61
+ if (this.description === undefined)
62
+ this.description = this.app.identity.web.description;
63
+
48
64
  // We render page & document separatly,
49
65
  // because document needs to access to runtime assigned values
50
66
  // Ex: runtime added scripts, title, metas, ....