@thzero/library_server 0.17.3 → 0.17.5
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 +93 -93
- package/boot/index.js +439 -431
- package/boot/plugins/admin/index.js +6 -6
- package/boot/plugins/admin/news.js +33 -33
- package/boot/plugins/admin/users.js +33 -33
- package/boot/plugins/api.js +57 -57
- package/boot/plugins/apiFront.js +31 -31
- package/boot/plugins/index.js +70 -70
- package/boot/plugins/news.js +44 -44
- package/boot/plugins/users.js +46 -46
- package/boot/plugins/usersExtended.js +32 -32
- package/constants.js +45 -45
- package/data/baseNews.js +42 -42
- package/data/baseSettingsUser.js +9 -9
- package/data/baseUser.js +28 -28
- package/data/index.js +24 -24
- package/data/named.js +20 -20
- package/errors/tokenExpired.js +7 -7
- package/license.md +8 -8
- package/openSource.js +66 -66
- package/package.json +34 -36
- package/repository/index.js +174 -174
- package/repository/usageMetrics/devnull.js +11 -11
- package/routes/index.js +76 -76
- package/service/admin/baseNews.js +45 -45
- package/service/admin/index.js +130 -130
- package/service/admin/news.js +6 -6
- package/service/admin/users.js +107 -107
- package/service/baseSecurity.js +44 -44
- package/service/baseUser.js +122 -122
- package/service/communication.js +6 -6
- package/service/config.js +32 -32
- package/service/crypto.js +16 -16
- package/service/discovery/index.js +6 -6
- package/service/discovery/resources/index.js +101 -101
- package/service/external.js +19 -19
- package/service/externalRest.js +19 -19
- package/service/index.js +20 -20
- package/service/monitoring.js +12 -12
- package/service/news/base.js +49 -49
- package/service/news/index.js +6 -6
- package/service/news/validation/index.js +6 -6
- package/service/plans.js +27 -27
- package/service/restCommunication.js +21 -21
- package/service/usageMetrics.js +57 -57
- package/service/utility.js +177 -177
- package/service/version.js +32 -32
- package/utility/injector.js +59 -59
- package/utility/internalIp/index.js +48 -48
- package/utility/list/doubleLinked.js +88 -88
- package/utility/list/priorityQueue.js +109 -109
- package/utility/list/queue.js +72 -72
- package/utility/os.js +20 -20
package/service/baseUser.js
CHANGED
|
@@ -1,122 +1,122 @@
|
|
|
1
|
-
import Service from './index.js';
|
|
2
|
-
|
|
3
|
-
import NotImplementedError from '@thzero/library_common/errors/notImplemented.js';
|
|
4
|
-
|
|
5
|
-
class BaseUserService extends Service {
|
|
6
|
-
async fetch(correlationId, userId) {
|
|
7
|
-
const validationCheckExternalIdResponse = this._serviceValidation.check(correlationId, this._serviceValidation.externalIdSchema, userId);
|
|
8
|
-
if (this._hasFailed(validationCheckExternalIdResponse))
|
|
9
|
-
return validationCheckExternalIdResponse;
|
|
10
|
-
|
|
11
|
-
const respositoryResponse = await this._repositoryUser.fetch(correlationId, userId);
|
|
12
|
-
return respositoryResponse;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async fetchByExternalId(correlationId, externalUserId) {
|
|
16
|
-
const validationCheckExternalIdResponse = this._serviceValidation.check(correlationId, this._serviceValidation.externalIdSchema, externalUserId);
|
|
17
|
-
if (this._hasFailed(validationCheckExternalIdResponse))
|
|
18
|
-
return validationCheckExternalIdResponse;
|
|
19
|
-
|
|
20
|
-
const respositoryResponse = await this._repositoryUser.fetchByExternalId(correlationId, externalUserId);
|
|
21
|
-
return respositoryResponse;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async fetchByGamerId(correlationId, requestedGamerId) {
|
|
25
|
-
const validationRequestedGamerIdResponse = this._serviceValidation.check(correlationId, this._serviceValidation.gamerIdSchema, requestedGamerId);
|
|
26
|
-
if (this._hasFailed(validationRequestedGamerIdResponse))
|
|
27
|
-
return validationRequestedGamerIdResponse;
|
|
28
|
-
|
|
29
|
-
const respositoryResponse = await this._repositoryUser.fetchByGamerId(correlationId, requestedGamerId);
|
|
30
|
-
return respositoryResponse;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
async fetchByGamerTag(correlationId, requestedUserGamerTag) {
|
|
34
|
-
const validationRequestedGamerTagResponse = this._serviceValidation.check(correlationId, this._serviceValidation.gamerTagSchema, requestedUserGamerTag);
|
|
35
|
-
if (this._hasFailed(validationRequestedGamerTagResponse))
|
|
36
|
-
return validationRequestedGamerTagResponse;
|
|
37
|
-
|
|
38
|
-
const respositoryResponse = await this._repositoryUser.fetchByGamerTag(correlationId, requestedUserGamerTag);
|
|
39
|
-
return respositoryResponse;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
async refreshSettings(correlationId, params) {
|
|
43
|
-
const validationCheckExternalIdResponse = this._serviceValidation.check(correlationId, this._serviceValidation.settingsRefreshSchema, params);
|
|
44
|
-
if (this._hasFailed(validationCheckExternalIdResponse))
|
|
45
|
-
return validationCheckExternalIdResponse;
|
|
46
|
-
|
|
47
|
-
const respositoryResponse = await this._repositoryUser.refreshSettings(correlationId, params.userId);
|
|
48
|
-
return respositoryResponse;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async update(correlationId, externalUser) {
|
|
52
|
-
const validationCheckExternalUserResponse = this._serviceValidation.check(correlationId, this._serviceValidation.externalUserSchema, externalUser);
|
|
53
|
-
if (this._hasFailed(validationCheckExternalUserResponse))
|
|
54
|
-
return validationCheckExternalUserResponse;
|
|
55
|
-
|
|
56
|
-
let user = null;
|
|
57
|
-
const respositoryResponse = await this._repositoryUser.fetchByExternalId(correlationId, externalUser.id, true);
|
|
58
|
-
if (this._hasSucceeded(respositoryResponse))
|
|
59
|
-
user = respositoryResponse.results;
|
|
60
|
-
|
|
61
|
-
if (!user) {
|
|
62
|
-
user = this._initiateUser();
|
|
63
|
-
user.id = externalUser.id;
|
|
64
|
-
user.planId = this._getDefaultPlan();
|
|
65
|
-
user.roles.push(this._getDefaultUserRole());
|
|
66
|
-
this._initializeUser(user);
|
|
67
|
-
}
|
|
68
|
-
user.external = externalUser;
|
|
69
|
-
if (externalUser) {
|
|
70
|
-
if (String.isNullOrEmpty(user.email)) {
|
|
71
|
-
if (!String.isNullOrEmpty(externalUser.email)) {
|
|
72
|
-
user.email = externalUser.email;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const respositoryExternalResponse = await this._repositoryUser.updateFromExternal(correlationId, user.id, user);
|
|
78
|
-
return respositoryExternalResponse;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
async updateSettings(correlationId, requestedSettings) {
|
|
82
|
-
const validationCheckSettingsResponse = this._serviceValidation.check(correlationId, this._serviceValidation.settingRequestSchema(), requestedSettings);
|
|
83
|
-
if (this._hasFailed(validationCheckSettingsResponse))
|
|
84
|
-
return validationCheckSettingsResponse;
|
|
85
|
-
|
|
86
|
-
const validationSettingsResponse = await this._updateSettingsValidation(correlationId, requestedSettings);
|
|
87
|
-
if (this._hasFailed(validationSettingsResponse))
|
|
88
|
-
return validationSettingsResponse;
|
|
89
|
-
|
|
90
|
-
const updateSettingsResponse = await this._updateSettings(correlationId, requestedSettings);
|
|
91
|
-
if (this._hasFailed(updateSettingsResponse))
|
|
92
|
-
return updateSettingsResponse;
|
|
93
|
-
|
|
94
|
-
const respositoryResponse = await this._repositoryUser.updateSettings(correlationId, requestedSettings.userId, requestedSettings.settings);
|
|
95
|
-
return respositoryResponse;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
_updateSettings(correlationId, requestedSettings) {
|
|
99
|
-
return this._success(correlationId);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
_updateSettingsValidation(correlationId, requestedSettings) {
|
|
103
|
-
return this._success(correlationId);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
_getDefaultPlan() {
|
|
107
|
-
return new NotImplementedError();
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
_getDefaultUserRole() {
|
|
111
|
-
return new NotImplementedError();
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
_initializeUser(user) {
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
get _repositoryUser() {
|
|
118
|
-
return new NotImplementedError();
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export default BaseUserService;
|
|
1
|
+
import Service from './index.js';
|
|
2
|
+
|
|
3
|
+
import NotImplementedError from '@thzero/library_common/errors/notImplemented.js';
|
|
4
|
+
|
|
5
|
+
class BaseUserService extends Service {
|
|
6
|
+
async fetch(correlationId, userId) {
|
|
7
|
+
const validationCheckExternalIdResponse = this._serviceValidation.check(correlationId, this._serviceValidation.externalIdSchema, userId);
|
|
8
|
+
if (this._hasFailed(validationCheckExternalIdResponse))
|
|
9
|
+
return validationCheckExternalIdResponse;
|
|
10
|
+
|
|
11
|
+
const respositoryResponse = await this._repositoryUser.fetch(correlationId, userId);
|
|
12
|
+
return respositoryResponse;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async fetchByExternalId(correlationId, externalUserId) {
|
|
16
|
+
const validationCheckExternalIdResponse = this._serviceValidation.check(correlationId, this._serviceValidation.externalIdSchema, externalUserId);
|
|
17
|
+
if (this._hasFailed(validationCheckExternalIdResponse))
|
|
18
|
+
return validationCheckExternalIdResponse;
|
|
19
|
+
|
|
20
|
+
const respositoryResponse = await this._repositoryUser.fetchByExternalId(correlationId, externalUserId);
|
|
21
|
+
return respositoryResponse;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async fetchByGamerId(correlationId, requestedGamerId) {
|
|
25
|
+
const validationRequestedGamerIdResponse = this._serviceValidation.check(correlationId, this._serviceValidation.gamerIdSchema, requestedGamerId);
|
|
26
|
+
if (this._hasFailed(validationRequestedGamerIdResponse))
|
|
27
|
+
return validationRequestedGamerIdResponse;
|
|
28
|
+
|
|
29
|
+
const respositoryResponse = await this._repositoryUser.fetchByGamerId(correlationId, requestedGamerId);
|
|
30
|
+
return respositoryResponse;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async fetchByGamerTag(correlationId, requestedUserGamerTag) {
|
|
34
|
+
const validationRequestedGamerTagResponse = this._serviceValidation.check(correlationId, this._serviceValidation.gamerTagSchema, requestedUserGamerTag);
|
|
35
|
+
if (this._hasFailed(validationRequestedGamerTagResponse))
|
|
36
|
+
return validationRequestedGamerTagResponse;
|
|
37
|
+
|
|
38
|
+
const respositoryResponse = await this._repositoryUser.fetchByGamerTag(correlationId, requestedUserGamerTag);
|
|
39
|
+
return respositoryResponse;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async refreshSettings(correlationId, params) {
|
|
43
|
+
const validationCheckExternalIdResponse = this._serviceValidation.check(correlationId, this._serviceValidation.settingsRefreshSchema, params);
|
|
44
|
+
if (this._hasFailed(validationCheckExternalIdResponse))
|
|
45
|
+
return validationCheckExternalIdResponse;
|
|
46
|
+
|
|
47
|
+
const respositoryResponse = await this._repositoryUser.refreshSettings(correlationId, params.userId);
|
|
48
|
+
return respositoryResponse;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async update(correlationId, externalUser) {
|
|
52
|
+
const validationCheckExternalUserResponse = this._serviceValidation.check(correlationId, this._serviceValidation.externalUserSchema, externalUser);
|
|
53
|
+
if (this._hasFailed(validationCheckExternalUserResponse))
|
|
54
|
+
return validationCheckExternalUserResponse;
|
|
55
|
+
|
|
56
|
+
let user = null;
|
|
57
|
+
const respositoryResponse = await this._repositoryUser.fetchByExternalId(correlationId, externalUser.id, true);
|
|
58
|
+
if (this._hasSucceeded(respositoryResponse))
|
|
59
|
+
user = respositoryResponse.results;
|
|
60
|
+
|
|
61
|
+
if (!user) {
|
|
62
|
+
user = this._initiateUser();
|
|
63
|
+
user.id = externalUser.id;
|
|
64
|
+
user.planId = this._getDefaultPlan();
|
|
65
|
+
user.roles.push(this._getDefaultUserRole());
|
|
66
|
+
this._initializeUser(user);
|
|
67
|
+
}
|
|
68
|
+
user.external = externalUser;
|
|
69
|
+
if (externalUser) {
|
|
70
|
+
if (String.isNullOrEmpty(user.email)) {
|
|
71
|
+
if (!String.isNullOrEmpty(externalUser.email)) {
|
|
72
|
+
user.email = externalUser.email;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const respositoryExternalResponse = await this._repositoryUser.updateFromExternal(correlationId, user.id, user);
|
|
78
|
+
return respositoryExternalResponse;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async updateSettings(correlationId, requestedSettings) {
|
|
82
|
+
const validationCheckSettingsResponse = this._serviceValidation.check(correlationId, this._serviceValidation.settingRequestSchema(), requestedSettings);
|
|
83
|
+
if (this._hasFailed(validationCheckSettingsResponse))
|
|
84
|
+
return validationCheckSettingsResponse;
|
|
85
|
+
|
|
86
|
+
const validationSettingsResponse = await this._updateSettingsValidation(correlationId, requestedSettings);
|
|
87
|
+
if (this._hasFailed(validationSettingsResponse))
|
|
88
|
+
return validationSettingsResponse;
|
|
89
|
+
|
|
90
|
+
const updateSettingsResponse = await this._updateSettings(correlationId, requestedSettings);
|
|
91
|
+
if (this._hasFailed(updateSettingsResponse))
|
|
92
|
+
return updateSettingsResponse;
|
|
93
|
+
|
|
94
|
+
const respositoryResponse = await this._repositoryUser.updateSettings(correlationId, requestedSettings.userId, requestedSettings.settings);
|
|
95
|
+
return respositoryResponse;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
_updateSettings(correlationId, requestedSettings) {
|
|
99
|
+
return this._success(correlationId);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
_updateSettingsValidation(correlationId, requestedSettings) {
|
|
103
|
+
return this._success(correlationId);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
_getDefaultPlan() {
|
|
107
|
+
return new NotImplementedError();
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
_getDefaultUserRole() {
|
|
111
|
+
return new NotImplementedError();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
_initializeUser(user) {
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
get _repositoryUser() {
|
|
118
|
+
return new NotImplementedError();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export default BaseUserService;
|
package/service/communication.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import Service from './index.js';
|
|
2
|
-
|
|
3
|
-
class CommunicationService extends Service {
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export default CommunicationService;
|
|
1
|
+
import Service from './index.js';
|
|
2
|
+
|
|
3
|
+
class CommunicationService extends Service {
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export default CommunicationService;
|
package/service/config.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import ConfigService from '@thzero/library_common_service/service/config.js';
|
|
2
|
-
|
|
3
|
-
class ServerConfigService extends ConfigService {
|
|
4
|
-
constructor(config) {
|
|
5
|
-
super(config);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
getBackend(key) {
|
|
9
|
-
if (String.isNullOrEmpty(key))
|
|
10
|
-
return null;
|
|
11
|
-
|
|
12
|
-
if (!this._config)
|
|
13
|
-
return null;
|
|
14
|
-
|
|
15
|
-
const configBackend = this._config.get('backend', null);
|
|
16
|
-
if (!configBackend)
|
|
17
|
-
return null;
|
|
18
|
-
|
|
19
|
-
if (!Array.isArray(configBackend))
|
|
20
|
-
return null;
|
|
21
|
-
|
|
22
|
-
key = key.toLowerCase();
|
|
23
|
-
for (const item of configBackend) {
|
|
24
|
-
if (item.key.toLowerCase() === key)
|
|
25
|
-
return item;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export default ServerConfigService;
|
|
1
|
+
import ConfigService from '@thzero/library_common_service/service/config.js';
|
|
2
|
+
|
|
3
|
+
class ServerConfigService extends ConfigService {
|
|
4
|
+
constructor(config) {
|
|
5
|
+
super(config);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
getBackend(key) {
|
|
9
|
+
if (String.isNullOrEmpty(key))
|
|
10
|
+
return null;
|
|
11
|
+
|
|
12
|
+
if (!this._config)
|
|
13
|
+
return null;
|
|
14
|
+
|
|
15
|
+
const configBackend = this._config.get('backend', null);
|
|
16
|
+
if (!configBackend)
|
|
17
|
+
return null;
|
|
18
|
+
|
|
19
|
+
if (!Array.isArray(configBackend))
|
|
20
|
+
return null;
|
|
21
|
+
|
|
22
|
+
key = key.toLowerCase();
|
|
23
|
+
for (const item of configBackend) {
|
|
24
|
+
if (item.key.toLowerCase() === key)
|
|
25
|
+
return item;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default ServerConfigService;
|
package/service/crypto.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import crypto from 'crypto';
|
|
2
|
-
|
|
3
|
-
import Service from './index.js';
|
|
4
|
-
|
|
5
|
-
const encoder = new TextEncoder();
|
|
6
|
-
|
|
7
|
-
class CryptoService extends Service {
|
|
8
|
-
async checksum(input, algorithm, encoding) {
|
|
9
|
-
return crypto
|
|
10
|
-
.createHash(algorithm || 'sha256')
|
|
11
|
-
.update(encoder.encode(input), 'utf8')
|
|
12
|
-
.digest(encoding || 'hex');
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export default CryptoService;
|
|
1
|
+
import crypto from 'crypto';
|
|
2
|
+
|
|
3
|
+
import Service from './index.js';
|
|
4
|
+
|
|
5
|
+
const encoder = new TextEncoder();
|
|
6
|
+
|
|
7
|
+
class CryptoService extends Service {
|
|
8
|
+
async checksum(input, algorithm, encoding) {
|
|
9
|
+
return crypto
|
|
10
|
+
.createHash(algorithm || 'sha256')
|
|
11
|
+
.update(encoder.encode(input), 'utf8')
|
|
12
|
+
.digest(encoding || 'hex');
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default CryptoService;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import BaseService from '@thzero/library_server/service/index.js';
|
|
2
|
-
|
|
3
|
-
class DiscoveryService extends BaseService {
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export default DiscoveryService;
|
|
1
|
+
import BaseService from '@thzero/library_server/service/index.js';
|
|
2
|
+
|
|
3
|
+
class DiscoveryService extends BaseService {
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export default DiscoveryService;
|
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
import NotImplementedError from '@thzero/library_common/errors/notImplemented.js';
|
|
2
|
-
|
|
3
|
-
import DiscoveryService from '../index.js';
|
|
4
|
-
|
|
5
|
-
class ResourcesDiscoveryService extends DiscoveryService {
|
|
6
|
-
async cleanup(correlationId) {
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
get allowsHeartbeat() {
|
|
10
|
-
return true;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
async cleanup(correlationId) {
|
|
14
|
-
try {
|
|
15
|
-
return this._cleanup(correlationId);
|
|
16
|
-
}
|
|
17
|
-
catch(err) {
|
|
18
|
-
return this._error('ResourceDiscoveryService', 'cleanup', null, err, null, null, correlationId);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
async deregister(correlationId, name) {
|
|
23
|
-
try {
|
|
24
|
-
this._enforceNotEmpty('ResourceDiscoveryService', 'deregister', name, 'name', correlationId);
|
|
25
|
-
|
|
26
|
-
return this._deregister(correlationId);
|
|
27
|
-
}
|
|
28
|
-
catch(err) {
|
|
29
|
-
return this._error('ResourceDiscoveryService', 'deregister', null, err, null, null, correlationId);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
async getService(correlationId, name) {
|
|
34
|
-
try {
|
|
35
|
-
this._enforceNotEmpty('ResourceDiscoveryService', 'getService', name, 'name', correlationId);
|
|
36
|
-
|
|
37
|
-
return this._getService(correlationId, name);
|
|
38
|
-
}
|
|
39
|
-
catch(err) {
|
|
40
|
-
return this._error('ResourceDiscoveryService', 'getService', null, err, null, null, correlationId);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// options { name, ttl, description }
|
|
45
|
-
async initialize(correlationId, opts) {
|
|
46
|
-
try {
|
|
47
|
-
this._enforceNotEmpty('ResourceDiscoveryService', 'initialize', opts, 'opts', correlationId);
|
|
48
|
-
this._enforceNotEmpty('ResourceDiscoveryService', 'initialize', opts.address, 'address', correlationId);
|
|
49
|
-
this._enforceNotNull('ResourceDiscoveryService', 'initialize', opts.port, 'port', correlationId);
|
|
50
|
-
|
|
51
|
-
return await this._initialize(correlationId, opts);
|
|
52
|
-
}
|
|
53
|
-
catch(err) {
|
|
54
|
-
return this._error('ResourceDiscoveryService', 'initialize', null, err, null, null, correlationId);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
async listing(correlationId) {
|
|
59
|
-
return this._listing(correlationId);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// options { name, ttl, description }
|
|
63
|
-
async register(correlationId, opts) {
|
|
64
|
-
try {
|
|
65
|
-
this._enforceNotEmpty('ResourceDiscoveryService', 'register', opts, 'opts', correlationId);
|
|
66
|
-
this._enforceNotEmpty('ResourceDiscoveryService', 'register', opts.address, 'address', correlationId);
|
|
67
|
-
this._enforceNotNull('ResourceDiscoveryService', 'register', opts.port, 'port', correlationId);
|
|
68
|
-
|
|
69
|
-
return await this._register(correlationId, opts);
|
|
70
|
-
}
|
|
71
|
-
catch(err) {
|
|
72
|
-
return this._error('ResourceDiscoveryService', 'register', null, err, null, null, correlationId);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
async _cleanup(correlationId) {
|
|
77
|
-
throw new NotImplementedError();
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
async _deregister(correlationId, name) {
|
|
81
|
-
throw new NotImplementedError();
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
async _getService(correlationId, name) {
|
|
85
|
-
throw new NotImplementedError();
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
async _initialize(correlationId, opts) {
|
|
89
|
-
throw new NotImplementedError();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
async _register(correlationId, opts) {
|
|
93
|
-
throw new NotImplementedError();
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
async _listing(correlationId) {
|
|
97
|
-
throw new NotImplementedError();
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export default ResourcesDiscoveryService;
|
|
1
|
+
import NotImplementedError from '@thzero/library_common/errors/notImplemented.js';
|
|
2
|
+
|
|
3
|
+
import DiscoveryService from '../index.js';
|
|
4
|
+
|
|
5
|
+
class ResourcesDiscoveryService extends DiscoveryService {
|
|
6
|
+
async cleanup(correlationId) {
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
get allowsHeartbeat() {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async cleanup(correlationId) {
|
|
14
|
+
try {
|
|
15
|
+
return this._cleanup(correlationId);
|
|
16
|
+
}
|
|
17
|
+
catch(err) {
|
|
18
|
+
return this._error('ResourceDiscoveryService', 'cleanup', null, err, null, null, correlationId);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async deregister(correlationId, name) {
|
|
23
|
+
try {
|
|
24
|
+
this._enforceNotEmpty('ResourceDiscoveryService', 'deregister', name, 'name', correlationId);
|
|
25
|
+
|
|
26
|
+
return this._deregister(correlationId);
|
|
27
|
+
}
|
|
28
|
+
catch(err) {
|
|
29
|
+
return this._error('ResourceDiscoveryService', 'deregister', null, err, null, null, correlationId);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async getService(correlationId, name) {
|
|
34
|
+
try {
|
|
35
|
+
this._enforceNotEmpty('ResourceDiscoveryService', 'getService', name, 'name', correlationId);
|
|
36
|
+
|
|
37
|
+
return this._getService(correlationId, name);
|
|
38
|
+
}
|
|
39
|
+
catch(err) {
|
|
40
|
+
return this._error('ResourceDiscoveryService', 'getService', null, err, null, null, correlationId);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// options { name, ttl, description }
|
|
45
|
+
async initialize(correlationId, opts) {
|
|
46
|
+
try {
|
|
47
|
+
this._enforceNotEmpty('ResourceDiscoveryService', 'initialize', opts, 'opts', correlationId);
|
|
48
|
+
this._enforceNotEmpty('ResourceDiscoveryService', 'initialize', opts.address, 'address', correlationId);
|
|
49
|
+
this._enforceNotNull('ResourceDiscoveryService', 'initialize', opts.port, 'port', correlationId);
|
|
50
|
+
|
|
51
|
+
return await this._initialize(correlationId, opts);
|
|
52
|
+
}
|
|
53
|
+
catch(err) {
|
|
54
|
+
return this._error('ResourceDiscoveryService', 'initialize', null, err, null, null, correlationId);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async listing(correlationId) {
|
|
59
|
+
return this._listing(correlationId);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// options { name, ttl, description }
|
|
63
|
+
async register(correlationId, opts) {
|
|
64
|
+
try {
|
|
65
|
+
this._enforceNotEmpty('ResourceDiscoveryService', 'register', opts, 'opts', correlationId);
|
|
66
|
+
this._enforceNotEmpty('ResourceDiscoveryService', 'register', opts.address, 'address', correlationId);
|
|
67
|
+
this._enforceNotNull('ResourceDiscoveryService', 'register', opts.port, 'port', correlationId);
|
|
68
|
+
|
|
69
|
+
return await this._register(correlationId, opts);
|
|
70
|
+
}
|
|
71
|
+
catch(err) {
|
|
72
|
+
return this._error('ResourceDiscoveryService', 'register', null, err, null, null, correlationId);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async _cleanup(correlationId) {
|
|
77
|
+
throw new NotImplementedError();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async _deregister(correlationId, name) {
|
|
81
|
+
throw new NotImplementedError();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async _getService(correlationId, name) {
|
|
85
|
+
throw new NotImplementedError();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async _initialize(correlationId, opts) {
|
|
89
|
+
throw new NotImplementedError();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async _register(correlationId, opts) {
|
|
93
|
+
throw new NotImplementedError();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async _listing(correlationId) {
|
|
97
|
+
throw new NotImplementedError();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export default ResourcesDiscoveryService;
|
package/service/external.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import LibraryConstants from '../constants';
|
|
2
|
-
|
|
3
|
-
import Service from './index.js';
|
|
4
|
-
|
|
5
|
-
class ExternalService extends Service {
|
|
6
|
-
constructor() {
|
|
7
|
-
super();
|
|
8
|
-
|
|
9
|
-
this._serviceCommunicationRest = null;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
async init(injector) {
|
|
13
|
-
await super.init(injector);
|
|
14
|
-
|
|
15
|
-
this._serviceCommunicationRest = this._injector.getService(LibraryConstants.InjectorKeys.SERVICE_COMMUNICATION_REST);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export default ExternalService;
|
|
1
|
+
import LibraryConstants from '../constants';
|
|
2
|
+
|
|
3
|
+
import Service from './index.js';
|
|
4
|
+
|
|
5
|
+
class ExternalService extends Service {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
|
|
9
|
+
this._serviceCommunicationRest = null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async init(injector) {
|
|
13
|
+
await super.init(injector);
|
|
14
|
+
|
|
15
|
+
this._serviceCommunicationRest = this._injector.getService(LibraryConstants.InjectorKeys.SERVICE_COMMUNICATION_REST);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default ExternalService;
|
package/service/externalRest.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import LibraryServerConstants from '../constants.js';
|
|
2
|
-
|
|
3
|
-
import ExternalService from './external.js';
|
|
4
|
-
|
|
5
|
-
class RestExternalService extends ExternalService {
|
|
6
|
-
constructor() {
|
|
7
|
-
super();
|
|
8
|
-
|
|
9
|
-
this._serviceCommunicationRest = null;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
async init(injector) {
|
|
13
|
-
await super.init(injector);
|
|
14
|
-
|
|
15
|
-
this._serviceCommunicationRest = this._injector.getService(LibraryServerConstants.InjectorKeys.SERVICE_COMMUNICATION_REST);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export default RestExternalService;
|
|
1
|
+
import LibraryServerConstants from '../constants.js';
|
|
2
|
+
|
|
3
|
+
import ExternalService from './external.js';
|
|
4
|
+
|
|
5
|
+
class RestExternalService extends ExternalService {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
|
|
9
|
+
this._serviceCommunicationRest = null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async init(injector) {
|
|
13
|
+
await super.init(injector);
|
|
14
|
+
|
|
15
|
+
this._serviceCommunicationRest = this._injector.getService(LibraryServerConstants.InjectorKeys.SERVICE_COMMUNICATION_REST);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default RestExternalService;
|