5htp-core 0.6.2-97 → 0.6.2-98

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.6.2-97",
4
+ "version": "0.6.2-98",
5
5
  "author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
6
6
  "repository": "git://github.com/gaetanlegac/5htp-core.git",
7
7
  "license": "MIT",
@@ -150,7 +150,9 @@ export abstract class Application<
150
150
  console.log('----------------------------------');
151
151
  console.log('- SERVICES');
152
152
  console.log('----------------------------------');
153
- await this.ready();
153
+ const startingServices = await this.ready();
154
+ await Promise.all(startingServices);
155
+ console.log('All services are ready');
154
156
  await this.runHook('ready');
155
157
 
156
158
  const startedTime = (Date.now() - startTime) / 1000;
@@ -179,12 +181,14 @@ export abstract class Application<
179
181
 
180
182
  public register( service: AnyService ) {
181
183
 
182
- service.ready();
184
+ return service.ready();
183
185
 
184
186
  }
185
187
 
186
188
  protected async ready() {
187
189
 
190
+ const startingServices: Promise<any>[] = [];
191
+
188
192
  // Print services
189
193
  const processService = async (propKey: string, service: AnyService, level: number = 0) => {
190
194
 
@@ -193,7 +197,8 @@ export abstract class Application<
193
197
 
194
198
  // Services start shouldn't block app boot
195
199
  // use await ServiceName.started to make services depends on each other
196
- this.starting = service.ready();
200
+ service.starting = service.ready();
201
+ startingServices.push(service.starting);
197
202
  service.status = 'running';
198
203
  console.log('-' + '-'.repeat(level * 1), propKey + ': ' + service.constructor.name);
199
204
 
@@ -253,6 +258,8 @@ export abstract class Application<
253
258
  // Services start shouldn't block app boot
254
259
  processService(serviceId, service);
255
260
  }
261
+
262
+ return startingServices;
256
263
  }
257
264
 
258
265
  }
@@ -50,8 +50,6 @@ export default class DisksManager<
50
50
  super(...args);
51
51
 
52
52
  const drivers = this.config.drivers;
53
-
54
- console.log('drivers', args);
55
53
 
56
54
  if (Object.keys( drivers ).length === 0)
57
55
  throw new Error("At least one disk driver should be mounted.");
@@ -168,11 +168,6 @@ export default class ServerRouter<
168
168
 
169
169
  public async ready() {
170
170
 
171
- // Every hours
172
- setInterval(() => {
173
- this.refreshStaticPages();
174
- }, 1000 * 60 * 60);
175
-
176
171
  // Detect router services
177
172
  for (const serviceName in this.config.plugins) {
178
173
  const service = this.config.plugins[serviceName];
@@ -216,6 +211,12 @@ export default class ServerRouter<
216
211
  );
217
212
  };
218
213
 
214
+
215
+ // When all the services are ready, initialize static routes
216
+ this.app.on('ready', () => {
217
+ this.initStaticRoutes();
218
+ });
219
+
219
220
  }
220
221
 
221
222
  public async shutdown() {
@@ -238,6 +239,8 @@ export default class ServerRouter<
238
239
 
239
240
  if (!rendered) {
240
241
 
242
+ console.log('[router] renderStatic: url', url);
243
+
241
244
  const fullUrl = this.url(url, {}, true);
242
245
  const response = await got( fullUrl, {
243
246
  method: 'GET',
@@ -266,6 +269,26 @@ export default class ServerRouter<
266
269
 
267
270
  }
268
271
 
272
+ private initStaticRoutes() {
273
+
274
+ for (const route of this.routes) {
275
+
276
+ if (!route.options.static)
277
+ continue;
278
+
279
+ // Add to static pages
280
+ // Should be a GET oage that don't take any parameter
281
+ for (const url of route.options.static.urls) {
282
+ this.renderStatic(url, route.options.static);
283
+ }
284
+ }
285
+
286
+ // Every hours, refresh static pages
287
+ setInterval(() => {
288
+ this.refreshStaticPages();
289
+ }, 1000 * 60 * 60);
290
+ }
291
+
269
292
  private refreshStaticPages() {
270
293
 
271
294
  console.log('[router] refreshStaticPages');
@@ -275,15 +298,10 @@ export default class ServerRouter<
275
298
  if (page.expire && page.expire < Date.now()) {
276
299
 
277
300
  this.renderStatic(pageUrl, page.options);
278
-
279
301
  }
280
302
  }
281
303
  }
282
304
 
283
-
284
-
285
-
286
-
287
305
  private registerRoutes(defModules: GlobImportedWithMetas<TRouteModule>) {
288
306
  for (const routeModule of defModules) {
289
307
 
@@ -332,14 +350,6 @@ export default class ServerRouter<
332
350
 
333
351
  this.routes.push(route);
334
352
 
335
- // Add to static pages
336
- // Should be a GET oage that don't take any parameter
337
- if (options.static) {
338
- for (const url of options.static.urls) {
339
- this.renderStatic(url, options.static);
340
- }
341
- }
342
-
343
353
  return this;
344
354
 
345
355
  }
package/types/icons.d.ts CHANGED
@@ -1 +1 @@
1
- export type TIcones = "solid/spinner-third"|"rocket"|"user-circle"|"times"|"at"|"star"|"plus"|"minus"|"trash"|"magnet"|"search"|"paper-plane"|"brands/linkedin"|"play"|"stop"|"check"|"plus-circle"|"clock"|"cog"|"ellipsis-h"|"long-arrow-right"|"lightbulb"|"long-arrow-left"|"phone"|"arrow-right"|"regular/shield-check"|"angle-down"|"plane-departure"|"comments-alt"|"user-shield"|"shield-alt"|"chart-line"|"money-bill-wave"|"link"|"file-alt"|"envelope"|"solid/crown"|"eye"|"pen"|"file"|"angle-up"|"user-plus"|"sack-dollar"|"info-circle"|"mouse-pointer"|"thumbs-up"|"dollar-sign"|"download"|"brands/google"|"brands/whatsapp"|"crown"|"check-circle"|"exclamation-circle"|"times-circle"|"arrow-left"|"broom"|"solid/check-circle"|"solid/exclamation-triangle"|"solid/times-circle"|"hourglass"|"key"|"building"|"briefcase"|"map-marker-alt"|"graduation-cap"|"angle-left"|"angle-right"|"plug"|"coin"|"coins"|"minus-circle"|"external-link"|"question-circle"|"arrow-to-bottom"|"magic"|"user"|"meh-rolling-eyes"|"unlink"|"bold"|"italic"|"underline"|"strikethrough"|"subscript"|"superscript"|"code"|"font"|"empty-set"|"horizontal-rule"|"page-break"|"image"|"table"|"poll"|"columns"|"sticky-note"|"caret-right"|"list-ul"|"check-square"|"h1"|"h2"|"h3"|"h4"|"list-ol"|"paragraph"|"quote-left"|"align-left"|"align-center"|"align-right"|"align-justify"|"indent"|"outdent"
1
+ export type TIcones = "solid/spinner-third"|"long-arrow-right"|"times-circle"|"brands/whatsapp"|"times"|"search"|"user"|"rocket"|"globe"|"bullhorn"|"briefcase"|"chart-line"|"handshake"|"ellipsis-h"|"brands/google"|"brands/reddit-alien"|"brands/linkedin-in"|"brands/github"|"robot"|"comments"|"user-friends"|"mouse-pointer"|"thumbs-up"|"dollar-sign"|"angle-down"|"info-circle"|"check-circle"|"exclamation-circle"|"heart"|"lock"|"eye"|"credit-card"|"at"|"brands/linkedin"|"key"|"bars"|"font"|"tag"|"compress"|"bolt"|"puzzle-piece"|"planet-ringed"|"chart-bar"|"power-off"|"exclamation"|"solid/download"|"database"|"solid/fire"|"usd-circle"|"lightbulb"|"download"|"solid/dollar-sign"|"bell"|"code"|"solid/clock"|"seedling"|"palette"|"car"|"plane"|"university"|"hard-hat"|"graduation-cap"|"cogs"|"film"|"leaf"|"tshirt"|"utensils"|"map-marked-alt"|"dumbbell"|"stethoscope"|"concierge-bell"|"book"|"shield-alt"|"gavel"|"industry"|"square-root-alt"|"newspaper"|"pills"|"medal"|"capsules"|"balance-scale"|"home"|"praying-hands"|"shopping-cart"|"flask"|"futbol"|"microchip"|"satellite-dish"|"shipping-fast"|"passport"|"tools"|"plus-circle"|"user-circle"|"brands/twitter"|"brands/facebook"|"comment-alt"|"list"|"file"|"plug"|"paper-plane"|"check"|"long-arrow-left"|"angle-left"|"angle-right"|"meh-rolling-eyes"|"trash"|"arrow-left"|"arrow-right"|"link"|"bold"|"italic"|"underline"|"strikethrough"|"subscript"|"superscript"|"unlink"|"pen"|"empty-set"|"horizontal-rule"|"page-break"|"image"|"table"|"poll"|"columns"|"sticky-note"|"caret-right"|"plus"|"align-left"|"align-center"|"align-right"|"align-justify"|"indent"|"outdent"|"list-ul"|"check-square"|"h1"|"h2"|"h3"|"h4"|"list-ol"|"paragraph"|"quote-left"