@thzero/library_server 0.16.1 → 0.16.3
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/README.md +4 -0
- package/boot/index.js +46 -19
- package/package.json +3 -3
- package/service/baseUser.js +3 -3
package/README.md
CHANGED
|
@@ -12,6 +12,10 @@ An opinionated library of common functionality to bootstrap an API application u
|
|
|
12
12
|
|
|
13
13
|
### Requirements
|
|
14
14
|
|
|
15
|
+
#### NodeJs
|
|
16
|
+
|
|
17
|
+
Requires [NodeJs ](https://nodejs.org) version 18+.
|
|
18
|
+
|
|
15
19
|
#### Mongo
|
|
16
20
|
|
|
17
21
|
Mongo is the only currently supposed option as the server side data source.
|
package/boot/index.js
CHANGED
|
@@ -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) {
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thzero/library_server",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.16.
|
|
4
|
+
"version": "0.16.3",
|
|
5
5
|
"version_major": 0,
|
|
6
6
|
"version_minor": 16,
|
|
7
|
-
"version_patch":
|
|
8
|
-
"version_date": "
|
|
7
|
+
"version_patch": 3,
|
|
8
|
+
"version_date": "11/21/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",
|
package/service/baseUser.js
CHANGED
|
@@ -53,11 +53,11 @@ class BaseUserService extends Service {
|
|
|
53
53
|
if (this._hasFailed(validationCheckExternalUserResponse))
|
|
54
54
|
return validationCheckExternalUserResponse;
|
|
55
55
|
|
|
56
|
+
let user = null;
|
|
56
57
|
const respositoryResponse = await this._repositoryUser.fetchByExternalId(correlationId, externalUser.id, true);
|
|
57
|
-
if (this.
|
|
58
|
-
|
|
58
|
+
if (this._hasSucceeded(respositoryResponse))
|
|
59
|
+
user = respositoryResponse.results;
|
|
59
60
|
|
|
60
|
-
let user = respositoryResponse.results;
|
|
61
61
|
if (!user) {
|
|
62
62
|
user = this._initiateUser();
|
|
63
63
|
user.id = externalUser.id;
|