@thzero/library_server 0.16.12 → 0.17.1
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 +12 -12
- package/boot/plugins/admin/news.js +3 -3
- package/boot/plugins/admin/users.js +3 -3
- package/boot/plugins/api.js +4 -4
- package/boot/plugins/apiFront.js +2 -2
- package/boot/plugins/news.js +4 -4
- package/boot/plugins/users.js +4 -4
- package/boot/plugins/usersExtended.js +4 -4
- package/data/index.js +4 -4
- package/license.md +1 -1
- package/package.json +6 -6
- package/service/admin/baseNews.js +3 -3
- package/service/admin/index.js +2 -2
- package/service/admin/users.js +4 -4
- package/service/externalRest.js +2 -2
- package/service/news/base.js +3 -3
- package/service/plans.js +2 -2
- package/service/usageMetrics.js +5 -5
- package/service/utility.js +6 -6
package/boot/index.js
CHANGED
|
@@ -4,10 +4,10 @@ import config from 'config';
|
|
|
4
4
|
|
|
5
5
|
import {internalIpV4} from '@thzero/library_server/utility/internalIp/index.js';
|
|
6
6
|
|
|
7
|
-
import
|
|
7
|
+
import LibraryServerConstants from '../constants.js';
|
|
8
8
|
import LibraryCommonServiceConstants from '@thzero/library_common_service/constants.js';
|
|
9
9
|
|
|
10
|
-
import
|
|
10
|
+
import LibraryCommonUtility from '@thzero/library_common/utility/index.js';
|
|
11
11
|
|
|
12
12
|
import NotImplementedError from '@thzero/library_common/errors/notImplemented.js';
|
|
13
13
|
|
|
@@ -96,7 +96,7 @@ class BootMain {
|
|
|
96
96
|
)
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
const healthcheckPath = this._appConfig.get('healthcheck.path',
|
|
99
|
+
const healthcheckPath = this._appConfig.get('healthcheck.path', LibraryServerConstants.HealthCheck.DefaultPath);
|
|
100
100
|
if (!healthcheckPath.startsWith('/'))
|
|
101
101
|
healthcheckPath = '/' + healthcheckPath;
|
|
102
102
|
|
|
@@ -213,7 +213,7 @@ class BootMain {
|
|
|
213
213
|
await pluginRepository.initRepositories(this._repositories);
|
|
214
214
|
|
|
215
215
|
await this._initRepositories();
|
|
216
|
-
this._injectRepository(
|
|
216
|
+
this._injectRepository(LibraryServerConstants.InjectorKeys.REPOSITORY_USAGE_METRIC, this._initRepositoriesUsageMetrics());
|
|
217
217
|
|
|
218
218
|
this._services = new Map();
|
|
219
219
|
|
|
@@ -227,15 +227,15 @@ class BootMain {
|
|
|
227
227
|
this._injectService(LibraryCommonServiceConstants.InjectorKeys.SERVICE_MONITORING, monitoringService);
|
|
228
228
|
|
|
229
229
|
this.usageMetricsServiceI = this._initServicesUsageMetrics();
|
|
230
|
-
this._injectService(
|
|
230
|
+
this._injectService(LibraryServerConstants.InjectorKeys.SERVICE_USAGE_METRIC, this.usageMetricsServiceI);
|
|
231
231
|
|
|
232
232
|
this.resourceDiscoveryServiceI = this._initServicesDiscoveryResources();
|
|
233
233
|
if (this.resourceDiscoveryServiceI)
|
|
234
|
-
this._injectService(
|
|
234
|
+
this._injectService(LibraryServerConstants.InjectorKeys.SERVICE_DISCOVERY_RESOURCES, this.resourceDiscoveryServiceI);
|
|
235
235
|
|
|
236
236
|
this.mdnsDiscoveryServiceI = this._initServicesDiscoveryMdns();
|
|
237
237
|
if (this.mdnsDiscoveryServiceI)
|
|
238
|
-
this._injectService(
|
|
238
|
+
this._injectService(LibraryServerConstants.InjectorKeys.SERVICE_DISCOVERY_MDNS, this.mdnsDiscoveryServiceI);
|
|
239
239
|
|
|
240
240
|
for (const pluginService of plugins)
|
|
241
241
|
await pluginService.initServices(this._services);
|
|
@@ -271,7 +271,7 @@ class BootMain {
|
|
|
271
271
|
this._servicesPost.set(key, value);
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
-
|
|
274
|
+
LibraryCommonUtility.initDateTime();
|
|
275
275
|
}
|
|
276
276
|
finally {
|
|
277
277
|
this._repositories = null;
|
|
@@ -354,15 +354,15 @@ class BootMain {
|
|
|
354
354
|
|
|
355
355
|
const opts = await this._initServerDiscoveryOpts();
|
|
356
356
|
|
|
357
|
-
await this._initServerDiscoveryMdns(
|
|
358
|
-
await this._initServerDiscoveryResources(
|
|
357
|
+
await this._initServerDiscoveryMdns(LibraryCommonUtility.cloneDeep(opts));
|
|
358
|
+
await this._initServerDiscoveryResources(LibraryCommonUtility.cloneDeep(opts));
|
|
359
359
|
}
|
|
360
360
|
|
|
361
361
|
async _initServerDiscoveryMdns(opts) {
|
|
362
362
|
if (!this.mdnsDiscoveryServiceI)
|
|
363
363
|
return;
|
|
364
364
|
|
|
365
|
-
await this.mdnsDiscoveryServiceI.initialize(
|
|
365
|
+
await this.mdnsDiscoveryServiceI.initialize(LibraryCommonUtility.generateId(), await this._initServerDiscoveryOptsMdns(opts));
|
|
366
366
|
}
|
|
367
367
|
|
|
368
368
|
async _initServerDiscoveryOpts() {
|
|
@@ -400,7 +400,7 @@ class BootMain {
|
|
|
400
400
|
if (!this.resourceDiscoveryServiceI)
|
|
401
401
|
return;
|
|
402
402
|
|
|
403
|
-
await this.resourceDiscoveryServiceI.initialize(
|
|
403
|
+
await this.resourceDiscoveryServiceI.initialize(LibraryCommonUtility.generateId(), await this._initServerDiscoveryOptsResources(opts));
|
|
404
404
|
}
|
|
405
405
|
|
|
406
406
|
_injectRepository(key, repository) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import LibraryServerConstants from '../../../constants.js';
|
|
2
2
|
|
|
3
3
|
import NotImplementedError from '@thzero/library_common/errors/notImplemented.js';
|
|
4
4
|
|
|
@@ -10,11 +10,11 @@ class NewsAdminBootPlugin extends AdminBootPlugin {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
async _initRepositories() {
|
|
13
|
-
this._injectRepository(
|
|
13
|
+
this._injectRepository(LibraryServerConstants.InjectorKeys.REPOSITORY_ADMIN_NEWS, this._initRepositoriesAdminNews());
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
async _initServices() {
|
|
17
|
-
this._injectService(
|
|
17
|
+
this._injectService(LibraryServerConstants.InjectorKeys.SERVICE_ADMIN_NEWS, this._initServicesAdminNews());
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
_initRepositoriesAdminNews() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import LibraryServerConstants from '../../../constants.js';
|
|
2
2
|
|
|
3
3
|
import NotImplementedError from '@thzero/library_common/errors/notImplemented.js';
|
|
4
4
|
|
|
@@ -10,11 +10,11 @@ class UsersAdminBootPlugin extends AdminBootPlugin {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
async _initRepositories() {
|
|
13
|
-
this._injectRepository(
|
|
13
|
+
this._injectRepository(LibraryServerConstants.InjectorKeys.REPOSITORY_ADMIN_USERS, this._initRepositoriesAdminUsers());
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
async _initServices() {
|
|
17
|
-
this._injectService(
|
|
17
|
+
this._injectService(LibraryServerConstants.InjectorKeys.SERVICE_ADMIN_USERS, this._initServicesAdminUsers());
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
_initRepositoriesAdminUsers() {
|
package/boot/plugins/api.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import LibraryServerConstants from '../../constants.js';
|
|
2
2
|
import LibraryCommonServiceConstants from '@thzero/library_common_service/constants.js';
|
|
3
3
|
|
|
4
4
|
import NotImplementedError from '@thzero/library_common/errors/notImplemented.js';
|
|
@@ -20,9 +20,9 @@ class ApiBootPlugin extends BootPlugin {
|
|
|
20
20
|
async _initServices() {
|
|
21
21
|
const communicationRestService = this._initServicesCommunicationRest();
|
|
22
22
|
if (communicationRestService)
|
|
23
|
-
this._injectService(
|
|
24
|
-
this._injectService(
|
|
25
|
-
this._injectService(
|
|
23
|
+
this._injectService(LibraryServerConstants.InjectorKeys.SERVICE_COMMUNICATION_REST, communicationRestService);
|
|
24
|
+
this._injectService(LibraryServerConstants.InjectorKeys.SERVICE_CRYPTO, this._initServicesCrypto());
|
|
25
|
+
this._injectService(LibraryServerConstants.InjectorKeys.SERVICE_VERSION, this._initServicesVersion());
|
|
26
26
|
|
|
27
27
|
const validationServices = this._initServicesValidation();
|
|
28
28
|
if (validationServices)
|
package/boot/plugins/apiFront.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import LibraryServerConstants from '../../constants.js';
|
|
2
2
|
|
|
3
3
|
import NotImplementedError from '@thzero/library_common/errors/notImplemented.js';
|
|
4
4
|
|
|
@@ -16,7 +16,7 @@ class FrontApiBootPlugin extends ApiBootPlugin {
|
|
|
16
16
|
async _initServices() {
|
|
17
17
|
super._initServices();
|
|
18
18
|
|
|
19
|
-
this._injectService(
|
|
19
|
+
this._injectService(LibraryServerConstants.InjectorKeys.SERVICE_UTILITY, this._initServicesUtility());
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
_initRoutesUtility() {
|
package/boot/plugins/news.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import LibraryServerConstants from '../../constants.js';
|
|
2
2
|
|
|
3
3
|
import NotImplementedError from '@thzero/library_common/errors/notImplemented.js';
|
|
4
4
|
|
|
@@ -14,14 +14,14 @@ class NewsApiBootPlugin extends BootPlugin {
|
|
|
14
14
|
async _initRepositories() {
|
|
15
15
|
await super._initRepositories();
|
|
16
16
|
|
|
17
|
-
this._injectRepository(
|
|
17
|
+
this._injectRepository(LibraryServerConstants.InjectorKeys.REPOSITORY_NEWS, this._initRepositoriesNews());
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
async _initServices() {
|
|
21
21
|
await super._initServices();
|
|
22
22
|
|
|
23
|
-
this._injectService(
|
|
24
|
-
this._injectService(
|
|
23
|
+
this._injectService(LibraryServerConstants.InjectorKeys.SERVICE_NEWS, this._initServicesNews());
|
|
24
|
+
this._injectService(LibraryServerConstants.InjectorKeys.SERVICE_VALIDATION_NEWS, this._initServicesNewsValidation());
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
_initRepositoriesNews() {
|
package/boot/plugins/users.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import LibraryServerConstants from '../../constants.js';
|
|
2
2
|
|
|
3
3
|
import NotImplementedError from '@thzero/library_common/errors/notImplemented.js';
|
|
4
4
|
|
|
@@ -16,14 +16,14 @@ class UsersApiBootPlugin extends BootPlugin {
|
|
|
16
16
|
async _initRepositories() {
|
|
17
17
|
await super._initRepositories();
|
|
18
18
|
|
|
19
|
-
this._injectRepository(
|
|
19
|
+
this._injectRepository(LibraryServerConstants.InjectorKeys.REPOSITORY_USERS, this._initRepositoriesUsers());
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
async _initServices() {
|
|
23
23
|
await super._initServices();
|
|
24
24
|
|
|
25
|
-
this._injectService(
|
|
26
|
-
this._injectService(
|
|
25
|
+
this._injectService(LibraryServerConstants.InjectorKeys.SERVICE_AUTH, this._initServicesAuth());
|
|
26
|
+
this._injectService(LibraryServerConstants.InjectorKeys.SERVICE_USERS, this._initServicesUser());
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
_initRepositoriesUsers() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import LibraryServerConstants from '../../constants.js';
|
|
2
2
|
|
|
3
3
|
import NotImplementedError from '@thzero/library_common/errors/notImplemented.js';
|
|
4
4
|
|
|
@@ -10,14 +10,14 @@ class ExtendedUsersApiBootPlugin extends UsersApiBootPlugin {
|
|
|
10
10
|
async _initRepositories() {
|
|
11
11
|
await super._initRepositories();
|
|
12
12
|
|
|
13
|
-
this._injectRepository(
|
|
13
|
+
this._injectRepository(LibraryServerConstants.InjectorKeys.REPOSITORY_PLANS, this._initRepositoriesPlans());
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
async _initServices() {
|
|
17
17
|
await super._initServices();
|
|
18
18
|
|
|
19
|
-
this._injectService(
|
|
20
|
-
this._injectService(
|
|
19
|
+
this._injectService(LibraryServerConstants.InjectorKeys.SERVICE_PLANS, this._initServicesPlans());
|
|
20
|
+
this._injectService(LibraryServerConstants.InjectorKeys.SERVICE_SECURITY, this._initServicesSecurity());
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
_initRepositoriesPlans() {
|
package/data/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import CommonUtility from '@thzero/library_common/utility/index.js';
|
|
2
2
|
|
|
3
3
|
class Data {
|
|
4
4
|
constructor() {
|
|
5
|
-
this.id =
|
|
6
|
-
this.createdTimestamp =
|
|
5
|
+
this.id = CommonUtility.generateId();
|
|
6
|
+
this.createdTimestamp = CommonUtility.getTimestamp();
|
|
7
7
|
this.createdUserId = null;
|
|
8
|
-
this.updatedTimestamp =
|
|
8
|
+
this.updatedTimestamp = CommonUtility.getTimestamp();
|
|
9
9
|
this.updatedUserId = null;
|
|
10
10
|
}
|
|
11
11
|
|
package/license.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2020-
|
|
3
|
+
Copyright (c) 2020-2023 thZero.com
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
6
|
|
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.17.1",
|
|
5
5
|
"version_major": 0,
|
|
6
|
-
"version_minor":
|
|
7
|
-
"version_patch":
|
|
8
|
-
"version_date": "
|
|
6
|
+
"version_minor": 17,
|
|
7
|
+
"version_patch": 1,
|
|
8
|
+
"version_date": "02/02/2023",
|
|
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",
|
|
@@ -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.17",
|
|
37
|
+
"@thzero/library_common_service": "^0.17"
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import LibraryServerConstants from '../../constants.js';
|
|
2
2
|
|
|
3
3
|
import BaseAdminService from './index.js';
|
|
4
4
|
|
|
@@ -16,9 +16,9 @@ class BaseNewsAdminService extends BaseAdminService {
|
|
|
16
16
|
async init(injector) {
|
|
17
17
|
await super.init(injector);
|
|
18
18
|
|
|
19
|
-
this._repositoryNews = this._injector.getService(
|
|
19
|
+
this._repositoryNews = this._injector.getService(LibraryServerConstants.InjectorKeys.REPOSITORY_ADMIN_NEWS);
|
|
20
20
|
|
|
21
|
-
this._serviceValidationNews = this._injector.getService(
|
|
21
|
+
this._serviceValidationNews = this._injector.getService(LibraryServerConstants.InjectorKeys.SERVICE_VALIDATION_NEWS);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
_initializeData() {
|
package/service/admin/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import LibraryCommonUtility from '@thzero/library_common/utility/index.js';
|
|
2
2
|
|
|
3
3
|
import NotImplementedError from '@thzero/library_common/errors/notImplemented.js';
|
|
4
4
|
|
|
@@ -63,7 +63,7 @@ class BaseAdminService extends Service {
|
|
|
63
63
|
let value = this._initializeData();
|
|
64
64
|
const fetchRespositoryResponse = await this._repository.fetch(correlationId, id);
|
|
65
65
|
if (this._hasSucceeded(fetchRespositoryResponse) && fetchRespositoryResponse.results)
|
|
66
|
-
value =
|
|
66
|
+
value = LibraryCommonUtility.map(this._initializeData(), fetchRespositoryResponse.results, true);
|
|
67
67
|
|
|
68
68
|
const validResponse = this._checkUpdatedTimestamp(correlationId, value, requestedValue, 'value');
|
|
69
69
|
if (this._hasFailed(validResponse))
|
package/service/admin/users.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import LibraryServerConstants from '../../constants.js';
|
|
2
2
|
|
|
3
3
|
import BaseAdminService from './index.js';
|
|
4
4
|
|
|
@@ -17,10 +17,10 @@ class BaseUsersAdminService extends BaseAdminService {
|
|
|
17
17
|
async init(injector) {
|
|
18
18
|
await super.init(injector);
|
|
19
19
|
|
|
20
|
-
this._repositoryUsers = this._injector.getService(
|
|
20
|
+
this._repositoryUsers = this._injector.getService(LibraryServerConstants.InjectorKeys.REPOSITORY_ADMIN_USERS);
|
|
21
21
|
|
|
22
|
-
this._serviceAuth = this._injector.getService(
|
|
23
|
-
this._serviceUser = this._injector.getService(
|
|
22
|
+
this._serviceAuth = this._injector.getService(LibraryServerConstants.InjectorKeys.SERVICE_AUTH);
|
|
23
|
+
this._serviceUser = this._injector.getService(LibraryServerConstants.InjectorKeys.SERVICE_USERS);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
async delete(correlationId, user, id) {
|
package/service/externalRest.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import LibraryServerConstants from '../constants.js';
|
|
2
2
|
|
|
3
3
|
import ExternalService from './external.js';
|
|
4
4
|
|
|
@@ -12,7 +12,7 @@ class RestExternalService extends ExternalService {
|
|
|
12
12
|
async init(injector) {
|
|
13
13
|
await super.init(injector);
|
|
14
14
|
|
|
15
|
-
this._serviceCommunicationRest = this._injector.getService(
|
|
15
|
+
this._serviceCommunicationRest = this._injector.getService(LibraryServerConstants.InjectorKeys.SERVICE_COMMUNICATION_REST);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
package/service/news/base.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import LibraryServerConstants from '../../constants.js';
|
|
2
2
|
|
|
3
3
|
import Service from '../../service/index.js';
|
|
4
4
|
|
|
@@ -14,9 +14,9 @@ class BaseNewsService extends Service {
|
|
|
14
14
|
async init(injector) {
|
|
15
15
|
await super.init(injector);
|
|
16
16
|
|
|
17
|
-
this._repositoryNewsI = this._injector.getService(
|
|
17
|
+
this._repositoryNewsI = this._injector.getService(LibraryServerConstants.InjectorKeys.REPOSITORY_NEWS);
|
|
18
18
|
|
|
19
|
-
this._serviceValidationNews = this._injector.getService(
|
|
19
|
+
this._serviceValidationNews = this._injector.getService(LibraryServerConstants.InjectorKeys.SERVICE_VALIDATION_NEWS);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
async latest(correlationId, user, timestamp) {
|
package/service/plans.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import LibraryServerConstants from '../constants.js';
|
|
2
2
|
|
|
3
3
|
import Service from './index.js';
|
|
4
4
|
|
|
@@ -12,7 +12,7 @@ class PlansService extends Service {
|
|
|
12
12
|
async init(injector) {
|
|
13
13
|
await super.init(injector);
|
|
14
14
|
|
|
15
|
-
this._repositoryPlansI = this._injector.getService(
|
|
15
|
+
this._repositoryPlansI = this._injector.getService(LibraryServerConstants.InjectorKeys.REPOSITORY_PLANS);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
async listing(correlationId) {
|
package/service/usageMetrics.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import LibraryServerConstants from '../constants.js';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import LibraryCommonUtility from '@thzero/library_common/utility/index.js';
|
|
4
4
|
|
|
5
5
|
import Service from './index.js';
|
|
6
6
|
|
|
@@ -16,7 +16,7 @@ class UsageMetricsService extends Service {
|
|
|
16
16
|
async init(injector) {
|
|
17
17
|
await super.init(injector);
|
|
18
18
|
|
|
19
|
-
this._repositoryUsageMetricsI = this._injector.getService(
|
|
19
|
+
this._repositoryUsageMetricsI = this._injector.getService(LibraryServerConstants.InjectorKeys.REPOSITORY_USAGE_METRIC);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
async register(usageMetrics, err) {
|
|
@@ -32,7 +32,7 @@ class UsageMetricsService extends Service {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
usageMetrics.date = new Date(new Date(
|
|
35
|
+
usageMetrics.date = new Date(new Date(LibraryCommonUtility.getTimestamp()).toISOString());
|
|
36
36
|
|
|
37
37
|
await this._repositoryUsageMetrics.register(usageMetrics);
|
|
38
38
|
return this._success(usageMetrics.correlationId);
|
|
@@ -50,7 +50,7 @@ class UsageMetricsService extends Service {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
get _repositoryUsageMetrics() {
|
|
53
|
-
return this._injector.getService(
|
|
53
|
+
return this._injector.getService(LibraryServerConstants.InjectorKeys.REPOSITORY_USAGE_METRIC)
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
package/service/utility.js
CHANGED
|
@@ -2,9 +2,9 @@ import fs from 'fs';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { Mutex as asyncMutex } from 'async-mutex';
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import LibraryServerConstants from '@thzero/library_server/constants.js';
|
|
6
6
|
|
|
7
|
-
import
|
|
7
|
+
import LibraryCommonUtility from '@thzero/library_common/utility/index.js';
|
|
8
8
|
|
|
9
9
|
import Service from './index.js';
|
|
10
10
|
|
|
@@ -26,14 +26,14 @@ class UtilityService extends Service {
|
|
|
26
26
|
async init(injector) {
|
|
27
27
|
await super.init(injector);
|
|
28
28
|
|
|
29
|
-
this._servicePlans = this._injector.getService(
|
|
30
|
-
this._serviceVersion = this._injector.getService(
|
|
29
|
+
this._servicePlans = this._injector.getService(LibraryServerConstants.InjectorKeys.SERVICE_PLANS);
|
|
30
|
+
this._serviceVersion = this._injector.getService(LibraryServerConstants.InjectorKeys.SERVICE_VERSION);
|
|
31
31
|
|
|
32
32
|
await this._initializeOopenSource();
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
async initialize(correlationId) {
|
|
36
|
-
const now =
|
|
36
|
+
const now = LibraryCommonUtility.getTimestamp();
|
|
37
37
|
const ttlInitialize = this._ttlInitialize ? this._ttlInitialize : 0;
|
|
38
38
|
const delta = now - ttlInitialize;
|
|
39
39
|
if (this._initializeResponse && (delta <= this._ttlInitializeDiff))
|
|
@@ -61,7 +61,7 @@ class UtilityService extends Service {
|
|
|
61
61
|
|
|
62
62
|
await this._intialize(correlationId, response);
|
|
63
63
|
|
|
64
|
-
this._ttlInitialize =
|
|
64
|
+
this._ttlInitialize = LibraryCommonUtility.getTimestamp();
|
|
65
65
|
this._initializeResponse = response;
|
|
66
66
|
return response;
|
|
67
67
|
}
|