@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 +58 -31
- package/boot/plugins/admin/index.js +1 -1
- package/boot/plugins/admin/news.js +3 -3
- package/boot/plugins/admin/users.js +3 -3
- package/boot/plugins/api.js +6 -6
- package/boot/plugins/apiFront.js +4 -4
- package/boot/plugins/news.js +3 -3
- package/boot/plugins/users.js +3 -3
- package/boot/plugins/usersExtended.js +4 -4
- package/data/baseNews.js +2 -2
- package/data/baseUser.js +2 -2
- package/data/index.js +1 -1
- package/data/named.js +1 -1
- package/package.json +7 -7
- package/repository/index.js +3 -3
- package/repository/usageMetrics/devnull.js +1 -1
- package/service/admin/baseNews.js +3 -3
- package/service/admin/index.js +3 -3
- package/service/admin/news.js +1 -1
- package/service/admin/users.js +3 -3
- package/service/baseSecurity.js +1 -1
- package/service/baseUser.js +2 -2
- package/service/communication.js +1 -1
- package/service/config.js +1 -1
- package/service/crypto.js +1 -1
- package/service/discovery/index.js +1 -1
- package/service/discovery/resources/index.js +2 -2
- package/service/external.js +1 -1
- package/service/externalRest.js +2 -2
- package/service/index.js +1 -1
- package/service/monitoring.js +1 -1
- package/service/news/base.js +2 -2
- package/service/news/index.js +1 -1
- package/service/news/validation/index.js +1 -1
- package/service/plans.js +2 -2
- package/service/restCommunication.js +1 -1
- package/service/usageMetrics.js +3 -3
- package/service/utility.js +1 -1
- package/service/version.js +1 -1
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
|
|
8
|
-
|
|
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
|
-
|
|
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,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() {
|
package/boot/plugins/api.js
CHANGED
|
@@ -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() {
|
package/boot/plugins/apiFront.js
CHANGED
|
@@ -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() {
|
package/boot/plugins/news.js
CHANGED
|
@@ -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() {
|
package/boot/plugins/users.js
CHANGED
|
@@ -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
package/data/named.js
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thzero/library_server",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.16.2",
|
|
5
5
|
"version_major": 0,
|
|
6
|
-
"version_minor":
|
|
7
|
-
"version_patch":
|
|
8
|
-
"version_date": "
|
|
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.
|
|
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.
|
|
37
|
-
"@thzero/library_common_service": "^0.
|
|
36
|
+
"@thzero/library_common": "^0.16",
|
|
37
|
+
"@thzero/library_common_service": "^0.16"
|
|
38
38
|
}
|
|
39
39
|
}
|
package/repository/index.js
CHANGED
|
@@ -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,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() {
|
package/service/admin/index.js
CHANGED
|
@@ -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) {
|
package/service/admin/news.js
CHANGED
package/service/admin/users.js
CHANGED
|
@@ -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() {
|
package/service/baseSecurity.js
CHANGED
package/service/baseUser.js
CHANGED
|
@@ -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) {
|
package/service/communication.js
CHANGED
package/service/config.js
CHANGED
package/service/crypto.js
CHANGED
|
@@ -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) {
|
package/service/external.js
CHANGED
package/service/externalRest.js
CHANGED
package/service/index.js
CHANGED
package/service/monitoring.js
CHANGED
package/service/news/base.js
CHANGED
package/service/news/index.js
CHANGED
package/service/plans.js
CHANGED
package/service/usageMetrics.js
CHANGED
|
@@ -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() {
|
package/service/utility.js
CHANGED