@thzero/library_server 0.15.44 → 0.16.2

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
@@ -1,17 +1,17 @@
1
- import {internalIpV6, internalIpV4} from '@thzero/library_server/utility/internalIp';
2
-
3
1
  import { createTerminus } from '@godaddy/terminus';
4
2
 
5
3
  import config from 'config';
6
4
 
7
- import LibraryConstants from '../constants';
8
- import LibraryCommonServiceConstants from '@thzero/library_common_service/constants';
5
+ import {internalIpV4} from '@thzero/library_server/utility/internalIp/index.js';
6
+
7
+ import LibraryConstants from '../constants.js';
8
+ import LibraryCommonServiceConstants from '@thzero/library_common_service/constants.js';
9
9
 
10
- import Utility from '@thzero/library_common/utility';
10
+ import Utility from '@thzero/library_common/utility/index.js';
11
11
 
12
- import NotImplementedError from '@thzero/library_common/errors/notImplemented';
12
+ import NotImplementedError from '@thzero/library_common/errors/notImplemented.js';
13
13
 
14
- import nullMonitoringService from '../service/monitoring';
14
+ import nullMonitoringService from '../service/monitoring.js';
15
15
 
16
16
  // require('@thzero/library_server/utility/string.cjs');
17
17
  String.isNullOrEmpty = function(value) {
@@ -29,13 +29,13 @@ String.trim = function(value) {
29
29
  return value.trim();
30
30
  }
31
31
 
32
- import injector from '@thzero/library_common/utility/injector';
32
+ import injector from '@thzero/library_common/utility/injector.js';
33
33
 
34
- import usageMetricsRepository from '../repository/usageMetrics/devnull';
34
+ import usageMetricsRepository from '../repository/usageMetrics/devnull.js';
35
35
 
36
- import configService from '../service/config';
37
- import loggerService from '@thzero/library_common_service/service/logger';
38
- import usageMetricsService from '../service/usageMetrics';
36
+ import configService from '../service/config.js';
37
+ import loggerService from '@thzero/library_common_service/service/logger.js';
38
+ import usageMetricsService from '../service/usageMetrics.js';
39
39
 
40
40
  class BootMain {
41
41
  async start(...args) {
@@ -54,13 +54,13 @@ class BootMain {
54
54
  const plugins = this._determinePlugins(args);
55
55
  await await this._initPlugins(plugins);
56
56
 
57
- this.ip = this._appConfig.get('ip', null);
58
- this.loggerServiceI.info2(`config.ip.override: ${this.ip}`);
59
- this.port = this._appConfig.get('port');
60
- this.loggerServiceI.info2(`config.port.override: ${this.port}`);
61
- this.loggerServiceI.info2(`process.env.PORT: ${process.env.PORT}`);
62
- this.port = process.env.PORT || this.port;
63
- this.loggerServiceI.info2(`selected.port: ${this.port}`);
57
+ // this.ip = this._appConfig.get('ip', null);
58
+ // this.loggerServiceI.info2(`config.ip.override: ${this.ip}`);
59
+ // this.port = this._appConfig.get('port');
60
+ // this.loggerServiceI.info2(`config.port.override: ${this.port}`);
61
+ // this.loggerServiceI.info2(`process.env.PORT: ${process.env.PORT}`);
62
+ // this.port = process.env.PORT || this.port;
63
+ // this.loggerServiceI.info2(`selected.port: ${this.port}`);
64
64
 
65
65
  const results = await this._initApp(args, plugins);
66
66
 
@@ -109,6 +109,43 @@ class BootMain {
109
109
  };
110
110
 
111
111
  createTerminus(results.server, terminusOptions);
112
+
113
+ // const self = this;
114
+ // const listen = async (port, address) => new Promise((resolve, reject) => {
115
+ // self._initAppListen(results.app, results.server, address, port, (err) => {
116
+ // if (err) {
117
+ // reject(err);
118
+ // return;
119
+ // }
120
+
121
+ // resolve();
122
+ // });
123
+ // });
124
+ // await listen(this.port, this.ip);
125
+ // this.address = results.server.address() ? results.server.address().address : null;
126
+ // if (this.address === '::')
127
+ // this.address = await internalIpV4();
128
+
129
+ await this._initServer(results.server);
130
+
131
+ for (const [key, value] of this._servicesPost) {
132
+ console.log(`services.init.post - ${key}`);
133
+ if (value.initPost)
134
+ await value.initPost();
135
+ }
136
+ this._initAppPost(results.app, args);
137
+
138
+ await this._initServerDiscovery(results.server);
139
+
140
+ console.log();
141
+ this.ip = this._appConfig.get('ip', null);
142
+ console.log(`config.ip.override: ${this.ip}`);
143
+ this.port = this._appConfig.get('port');
144
+ console.log(`config.port.override: ${this.port}`);
145
+ console.log(`process.env.PORT: ${process.env.PORT}`);
146
+ this.port = process.env.PORT || this.port;
147
+ console.log(`selected.port: ${this.port}`);
148
+ console.log();
112
149
 
113
150
  const self = this;
114
151
  const listen = async (port, address) => new Promise((resolve, reject) => {
@@ -126,18 +163,8 @@ class BootMain {
126
163
  if (this.address === '::')
127
164
  this.address = await internalIpV4();
128
165
 
129
- await this._initServer(results.server);
130
-
131
- for (const [key, value] of this._servicesPost) {
132
- console.log(`services.init.post - ${key}`);
133
- if (value.initPost)
134
- await value.initPost();
135
- }
136
- this._initAppPost(results.app, args);
137
-
138
- await this._initServerDiscovery(results.server);
139
-
140
- this.loggerServiceI.info2(`Starting HTTP on: `, this.address);
166
+ console.log();
167
+ console.log(`Starting HTTP on: ${this.address}:${this.port}`);
141
168
  }
142
169
 
143
170
  async _initApp(args, plugins) {
@@ -1,4 +1,4 @@
1
- import BootPlugin from '../index';
1
+ import BootPlugin from '../index.js';
2
2
 
3
3
  class AdminBootPlugin extends BootPlugin {
4
4
  }
@@ -1,8 +1,8 @@
1
- import LibraryConstants from '../../../constants';
1
+ import LibraryConstants from '../../../constants.js';
2
2
 
3
- import NotImplementedError from '@thzero/library_common/errors/notImplemented';
3
+ import NotImplementedError from '@thzero/library_common/errors/notImplemented.js';
4
4
 
5
- import AdminBootPlugin from './index';
5
+ import AdminBootPlugin from './index.js';
6
6
 
7
7
  class NewsAdminBootPlugin extends AdminBootPlugin {
8
8
  async _initRoutes() {
@@ -1,8 +1,8 @@
1
- import LibraryConstants from '../../../constants';
1
+ import LibraryConstants from '../../../constants.js';
2
2
 
3
- import NotImplementedError from '@thzero/library_common/errors/notImplemented';
3
+ import NotImplementedError from '@thzero/library_common/errors/notImplemented.js';
4
4
 
5
- import AdminBootPlugin from './index';
5
+ import AdminBootPlugin from './index.js';
6
6
 
7
7
  class UsersAdminBootPlugin extends AdminBootPlugin {
8
8
  async _initRoutes() {
@@ -1,12 +1,12 @@
1
- import LibraryConstants from '../../constants';
2
- import LibraryCommonServiceConstants from '@thzero/library_common_service/constants';
1
+ import LibraryConstants from '../../constants.js';
2
+ import LibraryCommonServiceConstants from '@thzero/library_common_service/constants.js';
3
3
 
4
- import NotImplementedError from '@thzero/library_common/errors/notImplemented';
4
+ import NotImplementedError from '@thzero/library_common/errors/notImplemented.js';
5
5
 
6
- import BootPlugin from './index';
6
+ import BootPlugin from './index.js';
7
7
 
8
- import cryptoService from '../../service/crypto';
9
- import versionService from '../../service/version';
8
+ import cryptoService from '../../service/crypto.js';
9
+ import versionService from '../../service/version.js';
10
10
 
11
11
  class ApiBootPlugin extends BootPlugin {
12
12
  async _initRoutesPost() {
@@ -1,10 +1,10 @@
1
- import LibraryConstants from '../../constants';
1
+ import LibraryConstants from '../../constants.js';
2
2
 
3
- import NotImplementedError from '@thzero/library_common/errors/notImplemented';
3
+ import NotImplementedError from '@thzero/library_common/errors/notImplemented.js';
4
4
 
5
- import ApiBootPlugin from './api';
5
+ import ApiBootPlugin from './api.js';
6
6
 
7
- import utilityService from '../../service/utility';
7
+ import utilityService from '../../service/utility.js';
8
8
 
9
9
  class FrontApiBootPlugin extends ApiBootPlugin {
10
10
  async _initRoutesPre() {
@@ -1,8 +1,8 @@
1
- import LibraryConstants from '../../constants';
1
+ import LibraryConstants from '../../constants.js';
2
2
 
3
- import NotImplementedError from '@thzero/library_common/errors/notImplemented';
3
+ import NotImplementedError from '@thzero/library_common/errors/notImplemented.js';
4
4
 
5
- import BootPlugin from './index';
5
+ import BootPlugin from './index.js';
6
6
 
7
7
  class NewsApiBootPlugin extends BootPlugin {
8
8
  async _initRoutes() {
@@ -1,8 +1,8 @@
1
- import LibraryConstants from '../../constants';
1
+ import LibraryConstants from '../../constants.js';
2
2
 
3
- import NotImplementedError from '@thzero/library_common/errors/notImplemented';
3
+ import NotImplementedError from '@thzero/library_common/errors/notImplemented.js';
4
4
 
5
- import BootPlugin from './index';
5
+ import BootPlugin from './index.js';
6
6
 
7
7
  class UsersApiBootPlugin extends BootPlugin {
8
8
  async _initRoutes() {
@@ -1,10 +1,10 @@
1
- import LibraryConstants from '../../constants';
1
+ import LibraryConstants from '../../constants.js';
2
2
 
3
- import NotImplementedError from '@thzero/library_common/errors/notImplemented';
3
+ import NotImplementedError from '@thzero/library_common/errors/notImplemented.js';
4
4
 
5
- import UsersApiBootPlugin from './users';
5
+ import UsersApiBootPlugin from './users.js';
6
6
 
7
- import plansService from '../../service/plans';
7
+ import plansService from '../../service/plans.js';
8
8
 
9
9
  class ExtendedUsersApiBootPlugin extends UsersApiBootPlugin {
10
10
  async _initRepositories() {
package/data/baseNews.js CHANGED
@@ -1,6 +1,6 @@
1
- import Data from './index';
1
+ import Data from './index.js';
2
2
 
3
- import NotImplementedError from '@thzero/library_common/errors/notImplemented';
3
+ import NotImplementedError from '@thzero/library_common/errors/notImplemented.js';
4
4
 
5
5
  class BaseNewsData extends Data {
6
6
  constructor() {
package/data/baseUser.js CHANGED
@@ -1,6 +1,6 @@
1
- import Data from './index';
1
+ import Data from './index.js';
2
2
 
3
- import NotImplementedError from '@thzero/library_common/errors/notImplemented';
3
+ import NotImplementedError from '@thzero/library_common/errors/notImplemented.js';
4
4
 
5
5
  class BaseUserData extends Data {
6
6
  constructor() {
package/data/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import Utility from '@thzero/library_common/utility';
1
+ import Utility from '@thzero/library_common/utility/index.js';
2
2
 
3
3
  class Data {
4
4
  constructor() {
package/data/named.js CHANGED
@@ -1,4 +1,4 @@
1
- import Data from './index';
1
+ import Data from './index.js';
2
2
 
3
3
  class NamedData extends Data {
4
4
  constructor() {
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@thzero/library_server",
3
3
  "type": "module",
4
- "version": "0.15.44",
4
+ "version": "0.16.2",
5
5
  "version_major": 0,
6
- "version_minor": 15,
7
- "version_patch": 44,
8
- "version_date": "05/28/2022",
6
+ "version_minor": 16,
7
+ "version_patch": 2,
8
+ "version_date": "08/28/2022",
9
9
  "description": "An opinionated library of common functionality to bootstrap an API application using MongoDb and Firebase. Currently either Fastify or Koa can be used as the web server.",
10
10
  "author": "thZero",
11
11
  "license": "MIT",
@@ -25,7 +25,7 @@
25
25
  "test": "echo \"Error: no test specified\" && exit 1"
26
26
  },
27
27
  "dependencies": {
28
- "@godaddy/terminus": "^4.10.2",
28
+ "@godaddy/terminus": "^4.11.1",
29
29
  "async-mutex": "^0.3.2",
30
30
  "config": "^3.3.7",
31
31
  "default-gateway": "^6.0.3",
@@ -33,7 +33,7 @@
33
33
  "ipaddr.js": "^2.0.1"
34
34
  },
35
35
  "peerDependencies": {
36
- "@thzero/library_common": "^0.15",
37
- "@thzero/library_common_service": "^0.15"
36
+ "@thzero/library_common": "^0.16",
37
+ "@thzero/library_common_service": "^0.16"
38
38
  }
39
39
  }
@@ -1,7 +1,7 @@
1
- import LibraryCommonServiceConstants from '@thzero/library_common_service/constants';
1
+ import LibraryCommonServiceConstants from '@thzero/library_common_service/constants.js';
2
2
 
3
- import Response from '@thzero/library_common/response';
4
- import ExtractResponse from '@thzero/library_common/response/extract';
3
+ import Response from '@thzero/library_common/response/index.js';
4
+ import ExtractResponse from '@thzero/library_common/response/extract.js';
5
5
 
6
6
  class Repository {
7
7
  async init(injector) {
@@ -1,4 +1,4 @@
1
- import Repository from '../index';
1
+ import Repository from '../index.js';
2
2
 
3
3
  class DevNullUsageMetricsRepository extends Repository {
4
4
  async register(usageMetrics) {
@@ -1,8 +1,8 @@
1
- import LibraryConstants from '../../constants';
1
+ import LibraryConstants from '../../constants.js';
2
2
 
3
- import BaseAdminService from './index';
3
+ import BaseAdminService from './index.js';
4
4
 
5
- import NotImplementedError from '@thzero/library_common/errors/notImplemented';
5
+ import NotImplementedError from '@thzero/library_common/errors/notImplemented.js';
6
6
 
7
7
  class BaseNewsAdminService extends BaseAdminService {
8
8
  constructor() {
@@ -1,8 +1,8 @@
1
- import Utility from '@thzero/library_common/utility';
1
+ import Utility from '@thzero/library_common/utility/index.js';
2
2
 
3
- import NotImplementedError from '@thzero/library_common/errors/notImplemented';
3
+ import NotImplementedError from '@thzero/library_common/errors/notImplemented.js';
4
4
 
5
- import Service from '../index';
5
+ import Service from '../index.js';
6
6
 
7
7
  class BaseAdminService extends Service {
8
8
  async create(correlationId, user, requestedValue) {
@@ -1,4 +1,4 @@
1
- import BaseNewsAdminService from './baseNews';
1
+ import BaseNewsAdminService from './baseNews.js';
2
2
 
3
3
  class NewsAdminService extends BaseNewsAdminService {
4
4
  }
@@ -1,8 +1,8 @@
1
- import LibraryConstants from '../../constants';
1
+ import LibraryConstants from '../../constants.js';
2
2
 
3
- import BaseAdminService from './index';
3
+ import BaseAdminService from './index.js';
4
4
 
5
- import NotImplementedError from '@thzero/library_common/errors/notImplemented';
5
+ import NotImplementedError from '@thzero/library_common/errors/notImplemented.js';
6
6
 
7
7
  class BaseUsersAdminService extends BaseAdminService {
8
8
  constructor() {
@@ -1,6 +1,6 @@
1
1
  import rbac from 'easy-rbac'
2
2
 
3
- import Service from './index';
3
+ import Service from './index.js';
4
4
 
5
5
  class BaseSecurityService extends Service {
6
6
  constructor() {
@@ -1,6 +1,6 @@
1
- import Service from './index';
1
+ import Service from './index.js';
2
2
 
3
- import NotImplementedError from '@thzero/library_common/errors/notImplemented';
3
+ import NotImplementedError from '@thzero/library_common/errors/notImplemented.js';
4
4
 
5
5
  class BaseUserService extends Service {
6
6
  async fetch(correlationId, userId) {
@@ -1,4 +1,4 @@
1
- import Service from './index';
1
+ import Service from './index.js';
2
2
 
3
3
  class CommunicationService extends Service {
4
4
  }
package/service/config.js CHANGED
@@ -1,4 +1,4 @@
1
- import ConfigService from '@thzero/library_common_service/service/config';
1
+ import ConfigService from '@thzero/library_common_service/service/config.js';
2
2
 
3
3
  class ServerConfigService extends ConfigService {
4
4
  constructor(config) {
package/service/crypto.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import crypto from 'crypto';
2
2
 
3
- import Service from './index';
3
+ import Service from './index.js';
4
4
 
5
5
  const encoder = new TextEncoder();
6
6
 
@@ -1,4 +1,4 @@
1
- import BaseService from '@thzero/library_server/service';
1
+ import BaseService from '@thzero/library_server/service/index.js';
2
2
 
3
3
  class DiscoveryService extends BaseService {
4
4
  }
@@ -1,6 +1,6 @@
1
- import NotImplementedError from '@thzero/library_common/errors/notImplemented';
1
+ import NotImplementedError from '@thzero/library_common/errors/notImplemented.js';
2
2
 
3
- import DiscoveryService from '../index';
3
+ import DiscoveryService from '../index.js';
4
4
 
5
5
  class ResourcesDiscoveryService extends DiscoveryService {
6
6
  async cleanup(correlationId) {
@@ -1,6 +1,6 @@
1
1
  import LibraryConstants from '../constants';
2
2
 
3
- import Service from './index';
3
+ import Service from './index.js';
4
4
 
5
5
  class ExternalService extends Service {
6
6
  constructor() {
@@ -1,6 +1,6 @@
1
- import LibraryConstants from '../constants';
1
+ import LibraryConstants from '../constants.js';
2
2
 
3
- import ExternalService from './external';
3
+ import ExternalService from './external.js';
4
4
 
5
5
  class RestExternalService extends ExternalService {
6
6
  constructor() {
package/service/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import Service from '@thzero/library_common_service/service/index';
1
+ import Service from '@thzero/library_common_service/service/index.js';
2
2
 
3
3
  class ServerService extends Service {
4
4
  constructor() {
@@ -1,4 +1,4 @@
1
- import BaseMonitoringService from '@thzero/library_common_service/service/monitoring';
1
+ import BaseMonitoringService from '@thzero/library_common_service/service/monitoring.js';
2
2
 
3
3
  class NullMonitoringService extends BaseMonitoringService {
4
4
  constructor() {
@@ -1,6 +1,6 @@
1
- import LibraryConstants from '../../constants';
1
+ import LibraryConstants from '../../constants.js';
2
2
 
3
- import Service from '../../service/index';
3
+ import Service from '../../service/index.js';
4
4
 
5
5
  class BaseNewsService extends Service {
6
6
  constructor() {
@@ -1,4 +1,4 @@
1
- import BaseNewsService from './base';
1
+ import BaseNewsService from './base.js';
2
2
 
3
3
  class NewsService extends BaseNewsService {
4
4
  }
@@ -1,4 +1,4 @@
1
- import BaseNewsJoiBaseValidationService from './joi';
1
+ import BaseNewsJoiBaseValidationService from './joi.js';
2
2
 
3
3
  class NewsValidationService extends BaseNewsJoiBaseValidationService {
4
4
  }
package/service/plans.js CHANGED
@@ -1,6 +1,6 @@
1
- import LibraryConstants from '../constants';
1
+ import LibraryConstants from '../constants.js';
2
2
 
3
- import Service from './index';
3
+ import Service from './index.js';
4
4
 
5
5
  class PlansService extends Service {
6
6
  constructor() {
@@ -1,4 +1,4 @@
1
- import CommunicationService from './communication';
1
+ import CommunicationService from './communication.js';
2
2
 
3
3
  class RestCommunicationService extends CommunicationService {
4
4
  // eslint-disable-next-line
@@ -1,8 +1,8 @@
1
- import LibraryConstants from '../constants';
1
+ import LibraryConstants from '../constants.js';
2
2
 
3
- import Utilities from '@thzero/library_common/utility/index';
3
+ import Utilities from '@thzero/library_common/utility/index.js';
4
4
 
5
- import Service from './index';
5
+ import Service from './index.js';
6
6
 
7
7
  class UsageMetricsService extends Service {
8
8
  constructor() {
@@ -1,4 +1,4 @@
1
- import Service from './index';
1
+ import Service from './index.js';
2
2
 
3
3
  class UtilityService extends Service {
4
4
  async logger(content, correlationId) {
@@ -1,7 +1,7 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
3
 
4
- import Service from './index';
4
+ import Service from './index.js';
5
5
 
6
6
  class VersionService extends Service {
7
7
  async version(correlationId) {