@thzero/library_server_fastify 0.15.36 → 0.15.39

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/boot/index.js CHANGED
@@ -9,7 +9,6 @@ import fastifyRoutes from 'fastify-routes';
9
9
  import fastifyStatic from 'fastify-static';
10
10
 
11
11
  import LibraryConstants from '@thzero/library_server/constants';
12
- import LibraryCommonServiceConstants from '@thzero/library_common_service/constants';
13
12
 
14
13
  import injector from '@thzero/library_common/utility/injector';
15
14
 
@@ -33,9 +32,16 @@ class FastifyBootMain extends BootMain {
33
32
 
34
33
  // return server;
35
34
  // };
35
+
36
+ let http2 = this._appConfig.get('http2', false);
37
+ http2 = http2 === 'true' ? true : false;
38
+ this.loggerServiceI.info2(`config.http2.override: ${http2}`);
36
39
 
37
40
  // const fastify = Fastify({ serverFactory, logger: true });
38
- const fastify = Fastify({ logger: true });
41
+ const fastify = Fastify({
42
+ http2: http2,
43
+ logger: true
44
+ });
39
45
  const serverHttp = fastify.server;
40
46
 
41
47
  await fastify.register(fastifyRoutes);
@@ -302,7 +308,11 @@ class FastifyBootMain extends BootMain {
302
308
  usageMetrics: this.usageMetricsServiceI
303
309
  });
304
310
 
305
- return { app: fastify, server: serverHttp, listen: fastify.listen };
311
+ return {
312
+ app: fastify,
313
+ server: serverHttp,
314
+ listen: fastify.listen
315
+ };
306
316
  }
307
317
 
308
318
  _initAuthentication(map) {
@@ -315,8 +325,8 @@ class FastifyBootMain extends BootMain {
315
325
  return map;
316
326
  }
317
327
 
318
- _initAppListen(app, server, port, err) {
319
- app.listen(port, err);
328
+ _initAppListen(app, server, address, port, err) {
329
+ app.listen(port, address, err);
320
330
  }
321
331
 
322
332
  async _initAppPost(app, args) {
@@ -12,6 +12,7 @@ class DefaultAuthenticationMiddleware {
12
12
  init(injector) {
13
13
  this._serviceAuth = injector.getService(LibraryConstants.InjectorKeys.SERVICE_AUTH);
14
14
  this._serviceLogger = injector.getService(LibraryCommonServiceConstants.InjectorKeys.SERVICE_LOGGER);
15
+ this._serviceUsageMetrics = injector.getService(LibraryConstants.InjectorKeys.SERVICE_USAGE_METRIC);
15
16
 
16
17
  return {
17
18
  callback: async (request, reply, done, options) => {
@@ -60,8 +61,7 @@ class DefaultAuthenticationMiddleware {
60
61
  querystring: request.query,
61
62
  token: request.token
62
63
  };
63
- const serviceUsageMetrics = request.server[LibraryConstants.InjectorKeys.SERVICE_USAGE_METRIC];
64
- await serviceUsageMetrics.register(usageMetrics).catch((err) => {
64
+ await this._serviceUsageMetrics.register(usageMetrics).catch((err) => {
65
65
  this._serviceLogger.error('middleware', 'authentication', err, null, request.correlationId);
66
66
  });
67
67
  })();
@@ -31,6 +31,7 @@ class DefaultAuthenticationMiddleware {
31
31
  this._serviceConfig = injector.getService(LibraryCommonServiceConstants.InjectorKeys.SERVICE_CONFIG);
32
32
  this._serviceLogger = injector.getService(LibraryCommonServiceConstants.InjectorKeys.SERVICE_LOGGER);
33
33
  this._serviceSecurity = injector.getService(LibraryConstants.InjectorKeys.SERVICE_SECURITY);
34
+ this._serviceUsageMetrics = injector.getService(LibraryConstants.InjectorKeys.SERVICE_USAGE_METRIC);
34
35
 
35
36
  return {
36
37
  callback: async (request, reply, done, options) => {
@@ -107,8 +108,7 @@ class DefaultAuthenticationMiddleware {
107
108
  querystring: request.query,
108
109
  token: request.token
109
110
  };
110
- const serviceUsageMetrics = request.server[LibraryConstants.InjectorKeys.SERVICE_USAGE_METRIC];
111
- await serviceUsageMetrics.register(usageMetrics).catch((err) => {
111
+ await this._serviceUsageMetrics.register(usageMetrics).catch((err) => {
112
112
  this._serviceLogger.error('middleware', 'authorization', err, null, request.correlationId);
113
113
  });
114
114
  })();
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@thzero/library_server_fastify",
3
3
  "type": "module",
4
- "version": "0.15.36",
4
+ "version": "0.15.39",
5
5
  "version_major": 0,
6
6
  "version_minor": 15,
7
- "version_patch": 36,
8
- "version_date": "04/22/2022",
7
+ "version_patch": 39,
8
+ "version_date": "04/25/2022",
9
9
  "description": "An opinionated library of common functionality to bootstrap a Fastify based API application.",
10
10
  "author": "thZero",
11
11
  "license": "MIT",