@thzero/library_server 0.16.6 → 0.16.7
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/openSource.js +67 -0
- package/package.json +3 -3
- package/service/utility.js +202 -0
package/openSource.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export default () => {
|
|
2
|
+
return [
|
|
3
|
+
{
|
|
4
|
+
category: 'server',
|
|
5
|
+
name: '@godaddy/terminus',
|
|
6
|
+
url: 'https://github.com/godaddy/terminus',
|
|
7
|
+
licenseName: 'MIT',
|
|
8
|
+
licenseUrl: 'https://github.com/godaddy/terminus/blob/master/LICENSE'
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
category: 'server',
|
|
12
|
+
name: '@thzero/library_common',
|
|
13
|
+
url: 'https://github.com/thzero/library_common',
|
|
14
|
+
licenseName: 'MIT',
|
|
15
|
+
licenseUrl: 'https://github.com/thzero/library_common/blob/master/license.md'
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
category: 'server',
|
|
19
|
+
name: '@thzero/library_common_service',
|
|
20
|
+
url: 'https://github.com/thzero/library_common_service',
|
|
21
|
+
licenseName: 'MIT',
|
|
22
|
+
licenseUrl: 'https://github.com/thzero/library_common_service/blob/master/license.md'
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
category: 'server',
|
|
26
|
+
name: '@thzero/library_service',
|
|
27
|
+
url: 'https://github.com/thzero/library_service',
|
|
28
|
+
licenseName: 'MIT',
|
|
29
|
+
licenseUrl: 'https://github.com/thzero/library_service/blob/master/license.md'
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
category: 'server',
|
|
33
|
+
name: 'async-mutex',
|
|
34
|
+
url: 'https://github.com/DirtyHairy/async-mutex',
|
|
35
|
+
licenseName: 'MIT',
|
|
36
|
+
licenseUrl: 'https://github.com/DirtyHairy/async-mutex/blob/master/LICENSE'
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
category: 'server',
|
|
40
|
+
name: 'config',
|
|
41
|
+
url: 'https://github.com/lorenwest/node-config',
|
|
42
|
+
licenseName: 'MIT',
|
|
43
|
+
licenseUrl: 'https://github.com/lorenwest/node-config/blob/master/LICENSE'
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
category: 'server',
|
|
47
|
+
name: 'default-gateway',
|
|
48
|
+
url: 'https://github.com/silverwind/default-gateway',
|
|
49
|
+
licenseName: 'BSD 2',
|
|
50
|
+
licenseUrl: 'https://github.com/silverwind/default-gateway/blob/master/LICENSE'
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
category: 'server',
|
|
54
|
+
name: 'easy-rbac',
|
|
55
|
+
url: 'https://github.com/DeadAlready/easy-rbac',
|
|
56
|
+
licenseName: 'MIT',
|
|
57
|
+
licenseUrl: 'https://github.com/DeadAlready/easy-rbac/blob/master/LICENSE'
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
category: 'server',
|
|
61
|
+
name: 'ipaddr.js',
|
|
62
|
+
url: 'https://github.com/whitequark/ipaddr.js',
|
|
63
|
+
licenseName: 'MIT',
|
|
64
|
+
licenseUrl: 'https://github.com/whitequark/ipaddr.js/blob/master/LICENSE'
|
|
65
|
+
}
|
|
66
|
+
];
|
|
67
|
+
}
|
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.7",
|
|
5
5
|
"version_major": 0,
|
|
6
6
|
"version_minor": 16,
|
|
7
|
-
"version_patch":
|
|
8
|
-
"version_date": "12/
|
|
7
|
+
"version_patch": 7,
|
|
8
|
+
"version_date": "12/20/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/utility.js
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
import LibraryConstants from '@thzero/library_server/constants.js';
|
|
5
|
+
|
|
1
6
|
import Service from './index.js';
|
|
2
7
|
|
|
3
8
|
class UtilityService extends Service {
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
|
|
12
|
+
this._servicePlans = null;
|
|
13
|
+
this._serviceVersion = null;
|
|
14
|
+
|
|
15
|
+
this._openSourceResponse = null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async init(injector) {
|
|
19
|
+
await super.init(injector);
|
|
20
|
+
|
|
21
|
+
this._servicePlans = this._injector.getService(LibraryConstants.InjectorKeys.SERVICE_PLANS);
|
|
22
|
+
this._serviceVersion = this._injector.getService(LibraryConstants.InjectorKeys.SERVICE_VERSION);
|
|
23
|
+
|
|
24
|
+
await this._initializeOopenSource();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async initialize(correlationId) {
|
|
28
|
+
const response = this._initResponse(correlationId);
|
|
29
|
+
response.results = {};
|
|
30
|
+
|
|
31
|
+
const responsePlans = await this._servicePlans.listing(correlationId);
|
|
32
|
+
if (this._hasFailed(responsePlans))
|
|
33
|
+
return responsePlans;
|
|
34
|
+
|
|
35
|
+
response.results.plans = responsePlans.results;
|
|
36
|
+
|
|
37
|
+
const responseVersion = await this._serviceVersion.version(correlationId);
|
|
38
|
+
if (this._hasFailed(responseVersion))
|
|
39
|
+
return responseVersion;
|
|
40
|
+
|
|
41
|
+
response.results.version = responseVersion.results;
|
|
42
|
+
|
|
43
|
+
this._intialize(correlationId, response);
|
|
44
|
+
|
|
45
|
+
return response;
|
|
46
|
+
}
|
|
47
|
+
|
|
4
48
|
async logger(content, correlationId) {
|
|
5
49
|
if (!content)
|
|
6
50
|
return this._error('UtilityService', 'logger');
|
|
@@ -32,6 +76,164 @@ class UtilityService extends Service {
|
|
|
32
76
|
|
|
33
77
|
return this._success(correlationId);
|
|
34
78
|
}
|
|
79
|
+
|
|
80
|
+
async openSource(correlationId) {
|
|
81
|
+
return this._openSourceResponse ? this._openSourceResponse : this._error();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
_intialize(correlationId, response) {
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async _initializeOopenSource(correlationId) {
|
|
88
|
+
this._openSourceResponse = this._initResponse(correlationId);
|
|
89
|
+
this._openSourceResponse.results = [];
|
|
90
|
+
|
|
91
|
+
try {
|
|
92
|
+
const __dirname = path.resolve();
|
|
93
|
+
const dir = path.join(path.resolve(__dirname), 'node_modules', '@thzero');
|
|
94
|
+
const dirs = await fs.promises.readdir(dir);
|
|
95
|
+
|
|
96
|
+
console.log(`\tOpenSource...`);
|
|
97
|
+
|
|
98
|
+
let file;
|
|
99
|
+
let importPath;
|
|
100
|
+
let fileI;
|
|
101
|
+
let items;
|
|
102
|
+
for (const item of dirs) {
|
|
103
|
+
try {
|
|
104
|
+
file = path.join(dir, item, 'openSource.js');
|
|
105
|
+
console.log(`\t${file}...`);
|
|
106
|
+
if (!fs.existsSync(file)){
|
|
107
|
+
console.log(`\t...not found.`);
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
importPath = ['@thzero', item, 'openSource.js'].join('/');
|
|
112
|
+
console.log(`\t${importPath}...`);
|
|
113
|
+
fileI = await import(importPath);
|
|
114
|
+
if (!fileI.default) {
|
|
115
|
+
console.log(`\t...failed to load.`);
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
items = fileI.default();
|
|
120
|
+
items.forEach(element => {
|
|
121
|
+
if (this._openSourceResponse.results.filter(l => l.name === element.name).length > 0)
|
|
122
|
+
return;
|
|
123
|
+
this._openSourceResponse.results.push(element);
|
|
124
|
+
});
|
|
125
|
+
console.log(`\t...processed.`);
|
|
126
|
+
}
|
|
127
|
+
catch(err) {
|
|
128
|
+
console.log(`\t...failed.`, err);
|
|
129
|
+
this._logger.warn('UtilityService', '_initializeOopenSource', null, err, correlationId);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
catch(err) {
|
|
134
|
+
this._logger.warn('UtilityService', '_initializeOopenSource', null, err, correlationId);
|
|
135
|
+
}
|
|
136
|
+
finally {
|
|
137
|
+
console.log(`\t...OpenSource`);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// response.results = await this._openSourceServer(correlationId);
|
|
141
|
+
this._openSource(correlationId, this._openSourceResponse.results);
|
|
142
|
+
|
|
143
|
+
this._openSourceResponse.results = this._openSourceResponse.results.sort((a, b) => a.name.localeCompare(b.name));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
_openSource(correlationId, openSource) {
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// async _openSourceServer(correlationId) {
|
|
150
|
+
// return [
|
|
151
|
+
// {
|
|
152
|
+
// category: 'server',
|
|
153
|
+
// name: '@thzero/library_common',
|
|
154
|
+
// url: 'https://github.com/thzero/library_common',
|
|
155
|
+
// licenseName: 'MIT',
|
|
156
|
+
// licenseUrl: 'https://github.com/thzero/library_common/blob/master/license.md'
|
|
157
|
+
// },
|
|
158
|
+
// {
|
|
159
|
+
// category: 'server',
|
|
160
|
+
// name: '@thzero/library_common_service',
|
|
161
|
+
// url: 'https://github.com/thzero/library_common_service',
|
|
162
|
+
// licenseName: 'MIT',
|
|
163
|
+
// licenseUrl: 'https://github.com/thzero/library_common_service/blob/master/license.md'
|
|
164
|
+
// },
|
|
165
|
+
// {
|
|
166
|
+
// category: 'server',
|
|
167
|
+
// name: '@thzero/library_server',
|
|
168
|
+
// url: 'https://github.com/thzero/library_server',
|
|
169
|
+
// licenseName: 'MIT',
|
|
170
|
+
// licenseUrl: 'https://github.com/thzero/library_server/blob/master/license.md'
|
|
171
|
+
// },
|
|
172
|
+
// {
|
|
173
|
+
// category: 'server',
|
|
174
|
+
// name: 'async-mutex',
|
|
175
|
+
// url: 'https://github.com/DirtyHairy/async-mutex',
|
|
176
|
+
// licenseName: 'MIT',
|
|
177
|
+
// licenseUrl: 'https://github.com/DirtyHairy/async-mutex/blob/master/LICENSE'
|
|
178
|
+
// },
|
|
179
|
+
// {
|
|
180
|
+
// category: 'server',
|
|
181
|
+
// name: 'config',
|
|
182
|
+
// url: 'https://github.com/lorenwest/node-config',
|
|
183
|
+
// licenseName: 'MIT',
|
|
184
|
+
// licenseUrl: 'https://github.com/lorenwest/node-config/blob/master/LICENSE'
|
|
185
|
+
// },
|
|
186
|
+
// {
|
|
187
|
+
// category: 'server',
|
|
188
|
+
// name: 'dayjs',
|
|
189
|
+
// url: 'https://github.com/iamkun/dayjs',
|
|
190
|
+
// licenseName: 'MIT',
|
|
191
|
+
// licenseUrl: 'https://github.com/iamkun/dayjs/blob/dev/LICENSE'
|
|
192
|
+
// },
|
|
193
|
+
// {
|
|
194
|
+
// category: 'server',
|
|
195
|
+
// name: 'dayjs-plugin-utc',
|
|
196
|
+
// url: 'https://github.com/guisturdy/dayjs-plugin-utc',
|
|
197
|
+
// licenseName: '??',
|
|
198
|
+
// licenseUrl: ''
|
|
199
|
+
// },
|
|
200
|
+
// {
|
|
201
|
+
// category: 'server',
|
|
202
|
+
// name: 'easy-rbac',
|
|
203
|
+
// url: 'https://github.com/DeadAlready/easy-rbac',
|
|
204
|
+
// licenseName: 'MIT',
|
|
205
|
+
// licenseUrl: 'https://github.com/DeadAlready/easy-rbac/blob/master/LICENSE'
|
|
206
|
+
// },
|
|
207
|
+
// {
|
|
208
|
+
// category: 'server',
|
|
209
|
+
// name: 'ipaddr.js',
|
|
210
|
+
// url: 'https://github.com/whitequark/ipaddr.js',
|
|
211
|
+
// licenseName: 'MIT',
|
|
212
|
+
// licenseUrl: 'https://github.com/whitequark/ipaddr.js/blob/master/LICENSE'
|
|
213
|
+
// },
|
|
214
|
+
// {
|
|
215
|
+
// category: 'client',
|
|
216
|
+
// name: 'lodash',
|
|
217
|
+
// url: 'https://github.com/lodash/lodash',
|
|
218
|
+
// licenseName: 'MIT',
|
|
219
|
+
// licenseUrl: 'https://github.com/lodash/lodash/blob/master/LICENSE'
|
|
220
|
+
// },
|
|
221
|
+
// {
|
|
222
|
+
// category: 'server',
|
|
223
|
+
// name: 'terminus',
|
|
224
|
+
// url: 'https://github.com/godaddy/terminus',
|
|
225
|
+
// licenseName: 'MIT',
|
|
226
|
+
// licenseUrl: 'https://github.com/godaddy/terminus/blob/master/LICENSE'
|
|
227
|
+
// },
|
|
228
|
+
// {
|
|
229
|
+
// category: 'server',
|
|
230
|
+
// name: 'uuid',
|
|
231
|
+
// url: 'https://github.com/kelektiv/node-uuid',
|
|
232
|
+
// licenseName: 'MIT',
|
|
233
|
+
// licenseUrl: 'https://github.com/kelektiv/node-uuid/blob/master/LICENSE.md'
|
|
234
|
+
// }
|
|
235
|
+
// ];
|
|
236
|
+
// }
|
|
35
237
|
}
|
|
36
238
|
|
|
37
239
|
export default UtilityService;
|