@twin.org/engine-server 0.0.1-next.9 → 0.0.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/dist/cjs/index.cjs +197 -444
- package/dist/esm/index.mjs +196 -444
- package/dist/types/engineServer.d.ts +23 -15
- package/dist/types/index.d.ts +1 -2
- package/dist/types/utils/engineServerConfigHelper.d.ts +11 -0
- package/docs/changelog.md +368 -1
- package/docs/reference/classes/EngineServer.md +79 -31
- package/docs/reference/functions/addDefaultRestPaths.md +17 -0
- package/docs/reference/functions/addDefaultSocketPaths.md +17 -0
- package/docs/reference/index.md +2 -5
- package/package.json +8 -68
- package/dist/types/components/authentication.d.ts +0 -11
- package/dist/types/components/information.d.ts +0 -11
- package/dist/types/components/mimeTypeProcessor.d.ts +0 -11
- package/dist/types/components/restRouteProcessor.d.ts +0 -11
- package/dist/types/components/socketRouteProcessor.d.ts +0 -11
- package/dist/types/models/IEngineServerEnvironmentVariables.d.ts +0 -41
- package/dist/types/utils/engineServerEnvBuilder.d.ts +0 -11
- package/docs/reference/functions/buildEngineServerConfiguration.md +0 -25
- package/docs/reference/interfaces/IEngineServerEnvironmentVariables.md +0 -75
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,263 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var apiAuthEntityStorageService = require('@twin.org/api-auth-entity-storage-service');
|
|
4
3
|
var apiModels = require('@twin.org/api-models');
|
|
5
4
|
var apiServerFastify = require('@twin.org/api-server-fastify');
|
|
6
|
-
var apiService = require('@twin.org/api-service');
|
|
7
|
-
var attestationService = require('@twin.org/attestation-service');
|
|
8
|
-
var auditableItemGraphService = require('@twin.org/auditable-item-graph-service');
|
|
9
|
-
var auditableItemStreamService = require('@twin.org/auditable-item-stream-service');
|
|
10
|
-
var blobStorageService = require('@twin.org/blob-storage-service');
|
|
11
5
|
var core = require('@twin.org/core');
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var identityService = require('@twin.org/identity-service');
|
|
15
|
-
var loggingService = require('@twin.org/logging-service');
|
|
16
|
-
var nftService = require('@twin.org/nft-service');
|
|
17
|
-
var telemetryService = require('@twin.org/telemetry-service');
|
|
18
|
-
var engineCore = require('@twin.org/engine-core');
|
|
19
|
-
var apiProcessors = require('@twin.org/api-processors');
|
|
6
|
+
var engineServerTypes = require('@twin.org/engine-server-types');
|
|
7
|
+
var modules = require('@twin.org/modules');
|
|
20
8
|
|
|
21
|
-
/**
|
|
22
|
-
* Initialise the authentication.
|
|
23
|
-
* @param engineCore The engine core.
|
|
24
|
-
* @param context The context for the engine.
|
|
25
|
-
* @param instanceConfig The instance config.
|
|
26
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
27
|
-
* @returns The name of the instance created.
|
|
28
|
-
* @throws GeneralError if the component type is unknown.
|
|
29
|
-
*/
|
|
30
|
-
function initialiseAuthenticationComponent(engineCore$1, context, instanceConfig, overrideInstanceType) {
|
|
31
|
-
engineCore$1.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
32
|
-
element: `Authentication Component: ${instanceConfig.type}`
|
|
33
|
-
}));
|
|
34
|
-
const type = instanceConfig.type;
|
|
35
|
-
let component;
|
|
36
|
-
let instanceType;
|
|
37
|
-
if (type === engineModels.AuthenticationComponentType.EntityStorage) {
|
|
38
|
-
apiAuthEntityStorageService.initSchema();
|
|
39
|
-
engineCore.initialiseEntityStorageConnector(engineCore$1, context, instanceConfig.options?.userEntityStorageType, "AuthenticationUser");
|
|
40
|
-
component = new apiAuthEntityStorageService.EntityStorageAuthenticationService({
|
|
41
|
-
vaultConnectorType: context.defaultTypes.vaultConnector,
|
|
42
|
-
...instanceConfig.options
|
|
43
|
-
});
|
|
44
|
-
instanceType = apiAuthEntityStorageService.EntityStorageAuthenticationService.NAMESPACE;
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
48
|
-
type,
|
|
49
|
-
componentType: "authenticationComponent"
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
53
|
-
context.componentInstances.push({
|
|
54
|
-
instanceType: finalInstanceType,
|
|
55
|
-
component
|
|
56
|
-
});
|
|
57
|
-
core.ComponentFactory.register(finalInstanceType, () => component);
|
|
58
|
-
return finalInstanceType;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Initialise the information component.
|
|
63
|
-
* @param engineCore The engine core.
|
|
64
|
-
* @param context The context for the engine.
|
|
65
|
-
* @param instanceConfig The instance config.
|
|
66
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
67
|
-
* @returns The name of the instance created.
|
|
68
|
-
* @throws GeneralError if the component type is unknown.
|
|
69
|
-
*/
|
|
70
|
-
function initialiseInformationComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
71
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
72
|
-
element: `Information Component: ${instanceConfig.type}`
|
|
73
|
-
}));
|
|
74
|
-
const type = instanceConfig.type;
|
|
75
|
-
let component;
|
|
76
|
-
let instanceType;
|
|
77
|
-
if (type === engineModels.InformationComponentType.Service) {
|
|
78
|
-
component = new apiService.InformationService(instanceConfig.options);
|
|
79
|
-
instanceType = apiService.InformationService.NAMESPACE;
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
83
|
-
type,
|
|
84
|
-
componentType: "informationComponent"
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
88
|
-
context.componentInstances.push({
|
|
89
|
-
instanceType: finalInstanceType,
|
|
90
|
-
component
|
|
91
|
-
});
|
|
92
|
-
core.ComponentFactory.register(finalInstanceType, () => component);
|
|
93
|
-
return finalInstanceType;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// Copyright 2024 IOTA Stiftung.
|
|
97
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
98
|
-
/**
|
|
99
|
-
* Initialise the mime type processor.
|
|
100
|
-
* @param engineCore The engine core.
|
|
101
|
-
* @param context The context for the engine.
|
|
102
|
-
* @param instanceConfig The instance config.
|
|
103
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
104
|
-
* @returns The name of the instance created.
|
|
105
|
-
* @throws GeneralError if the component type is unknown.
|
|
106
|
-
*/
|
|
107
|
-
function initialiseMimeTypeProcessorComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
108
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
109
|
-
element: `Mime Type Processor: ${instanceConfig.type}`
|
|
110
|
-
}));
|
|
111
|
-
const type = instanceConfig.type;
|
|
112
|
-
let component;
|
|
113
|
-
let instanceType;
|
|
114
|
-
if (type === engineModels.MimeTypeProcessorType.Jwt) {
|
|
115
|
-
component = new apiProcessors.JwtMimeTypeProcessor();
|
|
116
|
-
instanceType = apiProcessors.JwtMimeTypeProcessor.NAMESPACE;
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
120
|
-
type,
|
|
121
|
-
componentType: "mimeTypeProcessorComponent"
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
125
|
-
context.componentInstances.push({
|
|
126
|
-
instanceType: finalInstanceType,
|
|
127
|
-
component
|
|
128
|
-
});
|
|
129
|
-
apiModels.MimeTypeProcessorFactory.register(finalInstanceType, () => component);
|
|
130
|
-
return finalInstanceType;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// Copyright 2024 IOTA Stiftung.
|
|
134
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
135
|
-
/**
|
|
136
|
-
* Initialise the rest route processor.
|
|
137
|
-
* @param engineCore The engine core.
|
|
138
|
-
* @param context The context for the engine.
|
|
139
|
-
* @param instanceConfig The instance config.
|
|
140
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
141
|
-
* @returns The name of the instance created.
|
|
142
|
-
* @throws GeneralError if the component type is unknown.
|
|
143
|
-
*/
|
|
144
|
-
function initialiseRestRouteProcessorComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
145
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
146
|
-
element: `REST Route Processor: ${instanceConfig.type}`
|
|
147
|
-
}));
|
|
148
|
-
const type = instanceConfig.type;
|
|
149
|
-
let component;
|
|
150
|
-
let instanceType;
|
|
151
|
-
if (type === engineModels.RestRouteProcessorType.AuthHeader) {
|
|
152
|
-
component = new apiAuthEntityStorageService.AuthHeaderProcessor({
|
|
153
|
-
vaultConnectorType: context.defaultTypes.vaultConnector,
|
|
154
|
-
config: {
|
|
155
|
-
...instanceConfig.options?.config
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
instanceType = apiAuthEntityStorageService.AuthHeaderProcessor.NAMESPACE;
|
|
159
|
-
}
|
|
160
|
-
else if (type === engineModels.RestRouteProcessorType.Logging) {
|
|
161
|
-
component = new apiProcessors.LoggingProcessor({
|
|
162
|
-
loggingConnectorType: context.defaultTypes.loggingConnector,
|
|
163
|
-
config: {
|
|
164
|
-
...instanceConfig.options?.config
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
instanceType = apiProcessors.LoggingProcessor.NAMESPACE;
|
|
168
|
-
}
|
|
169
|
-
else if (type === engineModels.RestRouteProcessorType.NodeIdentity) {
|
|
170
|
-
component = new apiProcessors.NodeIdentityProcessor();
|
|
171
|
-
instanceType = apiProcessors.NodeIdentityProcessor.NAMESPACE;
|
|
172
|
-
}
|
|
173
|
-
else if (type === engineModels.RestRouteProcessorType.StaticUserIdentity) {
|
|
174
|
-
component = new apiProcessors.StaticUserIdentityProcessor(instanceConfig.options);
|
|
175
|
-
instanceType = apiProcessors.StaticUserIdentityProcessor.NAMESPACE;
|
|
176
|
-
}
|
|
177
|
-
else if (type === engineModels.RestRouteProcessorType.RestRoute) {
|
|
178
|
-
component = new apiProcessors.RestRouteProcessor(instanceConfig.options);
|
|
179
|
-
instanceType = apiProcessors.RestRouteProcessor.NAMESPACE;
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
183
|
-
type,
|
|
184
|
-
componentType: "restRouteProcessorComponent"
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
188
|
-
context.componentInstances.push({
|
|
189
|
-
instanceType: finalInstanceType,
|
|
190
|
-
component
|
|
191
|
-
});
|
|
192
|
-
apiModels.RestRouteProcessorFactory.register(finalInstanceType, () => component);
|
|
193
|
-
return finalInstanceType;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// Copyright 2024 IOTA Stiftung.
|
|
197
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
198
|
-
/**
|
|
199
|
-
* Initialise the socket route processor.
|
|
200
|
-
* @param engineCore The engine core.
|
|
201
|
-
* @param context The context for the engine.
|
|
202
|
-
* @param instanceConfig The instance config.
|
|
203
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
204
|
-
* @returns The name of the instance created.
|
|
205
|
-
* @throws GeneralError if the component type is unknown.
|
|
206
|
-
*/
|
|
207
|
-
function initialiseSocketRouteProcessorComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
208
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
209
|
-
element: `Socket Route Processor: ${instanceConfig.type}`
|
|
210
|
-
}));
|
|
211
|
-
const type = instanceConfig.type;
|
|
212
|
-
let component;
|
|
213
|
-
let instanceType;
|
|
214
|
-
if (type === engineModels.SocketRouteProcessorType.AuthHeader) {
|
|
215
|
-
component = new apiAuthEntityStorageService.AuthHeaderProcessor({
|
|
216
|
-
vaultConnectorType: context.defaultTypes.vaultConnector,
|
|
217
|
-
config: {
|
|
218
|
-
...instanceConfig.options?.config
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
instanceType = apiAuthEntityStorageService.AuthHeaderProcessor.NAMESPACE;
|
|
222
|
-
}
|
|
223
|
-
else if (type === engineModels.SocketRouteProcessorType.Logging) {
|
|
224
|
-
component = new apiProcessors.LoggingProcessor({
|
|
225
|
-
loggingConnectorType: context.defaultTypes.loggingConnector,
|
|
226
|
-
config: {
|
|
227
|
-
...instanceConfig.options?.config
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
instanceType = apiProcessors.LoggingProcessor.NAMESPACE;
|
|
231
|
-
}
|
|
232
|
-
else if (type === engineModels.SocketRouteProcessorType.NodeIdentity) {
|
|
233
|
-
component = new apiProcessors.NodeIdentityProcessor();
|
|
234
|
-
instanceType = apiProcessors.NodeIdentityProcessor.NAMESPACE;
|
|
235
|
-
}
|
|
236
|
-
else if (type === engineModels.SocketRouteProcessorType.StaticUserIdentity) {
|
|
237
|
-
component = new apiProcessors.StaticUserIdentityProcessor(instanceConfig.options);
|
|
238
|
-
instanceType = apiProcessors.StaticUserIdentityProcessor.NAMESPACE;
|
|
239
|
-
}
|
|
240
|
-
else if (type === engineModels.SocketRouteProcessorType.SocketRoute) {
|
|
241
|
-
component = new apiProcessors.SocketRouteProcessor(instanceConfig.options);
|
|
242
|
-
instanceType = apiProcessors.SocketRouteProcessor.NAMESPACE;
|
|
243
|
-
}
|
|
244
|
-
else {
|
|
245
|
-
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
246
|
-
type,
|
|
247
|
-
componentType: "socketRouteProcessorComponent"
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
251
|
-
context.componentInstances.push({
|
|
252
|
-
instanceType: finalInstanceType,
|
|
253
|
-
component
|
|
254
|
-
});
|
|
255
|
-
apiModels.SocketRouteProcessorFactory.register(finalInstanceType, () => component);
|
|
256
|
-
return finalInstanceType;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
// Copyright 2024 IOTA Stiftung.
|
|
260
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
261
9
|
/**
|
|
262
10
|
* Server for the engine.
|
|
263
11
|
*/
|
|
@@ -266,10 +14,6 @@ class EngineServer {
|
|
|
266
14
|
* Runtime name for the class.
|
|
267
15
|
*/
|
|
268
16
|
CLASS_NAME = "EngineServer";
|
|
269
|
-
/**
|
|
270
|
-
* The server config.
|
|
271
|
-
*/
|
|
272
|
-
_config;
|
|
273
17
|
/**
|
|
274
18
|
* The engine.
|
|
275
19
|
* @internal
|
|
@@ -295,25 +39,56 @@ class EngineServer {
|
|
|
295
39
|
* @internal
|
|
296
40
|
*/
|
|
297
41
|
_loggingConnectorType;
|
|
42
|
+
/**
|
|
43
|
+
* The REST routes for the application.
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
_restRoutes;
|
|
47
|
+
/**
|
|
48
|
+
* The Socket routes for the application.
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
_socketRoutes;
|
|
298
52
|
/**
|
|
299
53
|
* Create a new instance of EngineServer.
|
|
300
54
|
* @param options The options for the engine.
|
|
301
|
-
* @param options.server The server options for the engine.
|
|
302
55
|
* @param options.engineCore The engine core to serve from.
|
|
303
56
|
*/
|
|
304
57
|
constructor(options) {
|
|
305
58
|
core.Guards.object(this.CLASS_NAME, "options", options);
|
|
306
59
|
core.Guards.object(this.CLASS_NAME, "options.engineCore", options.engineCore);
|
|
307
|
-
this._config = options?.server ?? {};
|
|
308
60
|
this._engineCore = options.engineCore;
|
|
309
61
|
this._restRouteGenerators = [];
|
|
310
62
|
this._socketRouteGenerators = [];
|
|
63
|
+
this._restRoutes = [];
|
|
64
|
+
this._socketRoutes = [];
|
|
311
65
|
const coreConfig = this._engineCore.getConfig();
|
|
312
|
-
if (!core.Is.arrayValue(
|
|
313
|
-
|
|
66
|
+
if (!core.Is.arrayValue(coreConfig.types.restRouteProcessor)) {
|
|
67
|
+
coreConfig.types.restRouteProcessor = [];
|
|
68
|
+
if (!coreConfig.silent) {
|
|
69
|
+
coreConfig.types.restRouteProcessor.push({
|
|
70
|
+
type: engineServerTypes.RestRouteProcessorType.Logging,
|
|
71
|
+
options: {
|
|
72
|
+
config: {
|
|
73
|
+
includeBody: coreConfig.debug
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
coreConfig.types.restRouteProcessor.push({
|
|
79
|
+
type: engineServerTypes.RestRouteProcessorType.RestRoute,
|
|
80
|
+
options: {
|
|
81
|
+
config: {
|
|
82
|
+
includeErrorStack: coreConfig.debug
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
if (!core.Is.arrayValue(coreConfig.types.socketRouteProcessor)) {
|
|
88
|
+
coreConfig.types.socketRouteProcessor = [];
|
|
314
89
|
if (!coreConfig.silent) {
|
|
315
|
-
|
|
316
|
-
type:
|
|
90
|
+
coreConfig.types.socketRouteProcessor.push({
|
|
91
|
+
type: engineServerTypes.SocketRouteProcessorType.Logging,
|
|
317
92
|
options: {
|
|
318
93
|
config: {
|
|
319
94
|
includeBody: coreConfig.debug
|
|
@@ -321,8 +96,8 @@ class EngineServer {
|
|
|
321
96
|
}
|
|
322
97
|
});
|
|
323
98
|
}
|
|
324
|
-
|
|
325
|
-
type:
|
|
99
|
+
coreConfig.types.socketRouteProcessor.push({
|
|
100
|
+
type: engineServerTypes.SocketRouteProcessorType.SocketRoute,
|
|
326
101
|
options: {
|
|
327
102
|
config: {
|
|
328
103
|
includeErrorStack: coreConfig.debug
|
|
@@ -338,14 +113,16 @@ class EngineServer {
|
|
|
338
113
|
* Add a REST route generator.
|
|
339
114
|
* @param type The type to add the generator for.
|
|
340
115
|
* @param typeConfig The type config.
|
|
341
|
-
* @param
|
|
116
|
+
* @param module The module containing the generator.
|
|
117
|
+
* @param method The method to call on the module.
|
|
342
118
|
*/
|
|
343
|
-
addRestRouteGenerator(type, typeConfig,
|
|
119
|
+
addRestRouteGenerator(type, typeConfig, module, method) {
|
|
344
120
|
if (!core.Is.empty(typeConfig)) {
|
|
345
121
|
this._restRouteGenerators.push({
|
|
346
122
|
type,
|
|
347
123
|
typeConfig,
|
|
348
|
-
|
|
124
|
+
module,
|
|
125
|
+
method
|
|
349
126
|
});
|
|
350
127
|
}
|
|
351
128
|
}
|
|
@@ -353,24 +130,43 @@ class EngineServer {
|
|
|
353
130
|
* Add a socket route generator.
|
|
354
131
|
* @param type The type to add the generator for.
|
|
355
132
|
* @param typeConfig The type config.
|
|
356
|
-
* @param
|
|
133
|
+
* @param module The module containing the generator.
|
|
134
|
+
* @param method The method to call on the module.
|
|
357
135
|
*/
|
|
358
|
-
addSocketRouteGenerator(type, typeConfig,
|
|
136
|
+
addSocketRouteGenerator(type, typeConfig, module, method) {
|
|
359
137
|
if (!core.Is.empty(typeConfig)) {
|
|
360
138
|
this._socketRouteGenerators.push({
|
|
361
139
|
type,
|
|
362
140
|
typeConfig,
|
|
363
|
-
|
|
141
|
+
module,
|
|
142
|
+
method
|
|
364
143
|
});
|
|
365
144
|
}
|
|
366
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Get the built REST routes.
|
|
148
|
+
* @returns The REST routes.
|
|
149
|
+
*/
|
|
150
|
+
getRestRoutes() {
|
|
151
|
+
return this._restRoutes;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Get the built socket routes.
|
|
155
|
+
* @returns The socket routes.
|
|
156
|
+
*/
|
|
157
|
+
getSocketRoutes() {
|
|
158
|
+
return this._socketRoutes;
|
|
159
|
+
}
|
|
367
160
|
/**
|
|
368
161
|
* Start the engine server.
|
|
369
|
-
* @returns
|
|
162
|
+
* @returns True if the start was successful.
|
|
370
163
|
*/
|
|
371
164
|
async start() {
|
|
372
|
-
await this._engineCore.start();
|
|
373
|
-
|
|
165
|
+
const canContinue = await this._engineCore.start();
|
|
166
|
+
if (canContinue) {
|
|
167
|
+
await this.startWebServer();
|
|
168
|
+
}
|
|
169
|
+
return canContinue;
|
|
374
170
|
}
|
|
375
171
|
/**
|
|
376
172
|
* Stop the engine server.
|
|
@@ -388,8 +184,8 @@ class EngineServer {
|
|
|
388
184
|
* @internal
|
|
389
185
|
*/
|
|
390
186
|
async startWebServer() {
|
|
391
|
-
|
|
392
|
-
|
|
187
|
+
this._restRoutes = await this.buildRestRoutes();
|
|
188
|
+
this._socketRoutes = await this.buildSocketRoutes();
|
|
393
189
|
const restRouteProcessors = apiModels.RestRouteProcessorFactory.names().map(n => apiModels.RestRouteProcessorFactory.get(n));
|
|
394
190
|
const socketRouteProcessors = apiModels.SocketRouteProcessorFactory.names().map(n => apiModels.SocketRouteProcessorFactory.get(n));
|
|
395
191
|
const mimeTypeProcessors = apiModels.MimeTypeProcessorFactory.names().map(n => apiModels.MimeTypeProcessorFactory.get(n));
|
|
@@ -400,7 +196,7 @@ class EngineServer {
|
|
|
400
196
|
loggingConnectorType: this._loggingConnectorType,
|
|
401
197
|
mimeTypeProcessors
|
|
402
198
|
});
|
|
403
|
-
await this._webServer.build(restRouteProcessors,
|
|
199
|
+
await this._webServer.build(restRouteProcessors, this._restRoutes, socketRouteProcessors, this._socketRoutes, coreConfig.web);
|
|
404
200
|
await this._webServer.start();
|
|
405
201
|
}
|
|
406
202
|
/**
|
|
@@ -408,10 +204,10 @@ class EngineServer {
|
|
|
408
204
|
* @returns The REST routes for the application.
|
|
409
205
|
* @internal
|
|
410
206
|
*/
|
|
411
|
-
buildRestRoutes() {
|
|
207
|
+
async buildRestRoutes() {
|
|
412
208
|
const routes = [];
|
|
413
|
-
for (const { type, typeConfig,
|
|
414
|
-
this.initialiseRestTypeRoute(routes, type, typeConfig,
|
|
209
|
+
for (const { type, typeConfig, module, method } of this._restRouteGenerators) {
|
|
210
|
+
await this.initialiseRestTypeRoute(routes, type, typeConfig, module, method);
|
|
415
211
|
}
|
|
416
212
|
return routes;
|
|
417
213
|
}
|
|
@@ -420,10 +216,10 @@ class EngineServer {
|
|
|
420
216
|
* @returns The socket routes for the application.
|
|
421
217
|
* @internal
|
|
422
218
|
*/
|
|
423
|
-
buildSocketRoutes() {
|
|
219
|
+
async buildSocketRoutes() {
|
|
424
220
|
const routes = [];
|
|
425
|
-
for (const { type, typeConfig,
|
|
426
|
-
this.initialiseSocketTypeRoute(routes, type, typeConfig,
|
|
221
|
+
for (const { type, typeConfig, module, method } of this._socketRouteGenerators) {
|
|
222
|
+
await this.initialiseSocketTypeRoute(routes, type, typeConfig, module, method);
|
|
427
223
|
}
|
|
428
224
|
return routes;
|
|
429
225
|
}
|
|
@@ -435,31 +231,41 @@ class EngineServer {
|
|
|
435
231
|
* @param generateRoutes The function to generate the routes.
|
|
436
232
|
* @internal
|
|
437
233
|
*/
|
|
438
|
-
initialiseRestTypeRoute(routes, typeKey, typeConfig,
|
|
234
|
+
async initialiseRestTypeRoute(routes, typeKey, typeConfig, module, method) {
|
|
439
235
|
if (core.Is.arrayValue(typeConfig)) {
|
|
440
236
|
const defaultEngineTypes = this._engineCore.getDefaultTypes();
|
|
237
|
+
const generateRoutes = await modules.ModuleHelper.getModuleEntry(module, method);
|
|
441
238
|
for (let i = 0; i < typeConfig.length; i++) {
|
|
442
239
|
const restPath = typeConfig[i].restPath;
|
|
443
240
|
if (core.Is.string(restPath)) {
|
|
444
241
|
const serviceType = typeConfig[i].overrideInstanceType ?? defaultEngineTypes[typeKey];
|
|
445
242
|
if (core.Is.stringValue(serviceType)) {
|
|
446
|
-
|
|
243
|
+
const generatedRoutes = generateRoutes(restPath, serviceType);
|
|
244
|
+
for (const route of generatedRoutes) {
|
|
245
|
+
// Don't strip trailing slashes from the root path.
|
|
246
|
+
if (core.Is.stringValue(route.path) && route.path.length > 1) {
|
|
247
|
+
route.path = core.StringHelper.trimTrailingSlashes(route.path);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
routes.push(...generatedRoutes);
|
|
447
251
|
}
|
|
448
252
|
}
|
|
449
253
|
}
|
|
450
254
|
}
|
|
451
255
|
}
|
|
452
256
|
/**
|
|
453
|
-
* Initialise the
|
|
257
|
+
* Initialise the socket routes from connector.
|
|
454
258
|
* @param routes The routes to add to.
|
|
455
259
|
* @param typeKey The key for the default types.
|
|
456
260
|
* @param typeConfig The type config.
|
|
457
|
-
* @param
|
|
261
|
+
* @param module The module containing the generator.
|
|
262
|
+
* @param method The method to call on the module.
|
|
458
263
|
* @internal
|
|
459
264
|
*/
|
|
460
|
-
initialiseSocketTypeRoute(routes, typeKey, typeConfig,
|
|
265
|
+
async initialiseSocketTypeRoute(routes, typeKey, typeConfig, module, method) {
|
|
461
266
|
if (core.Is.arrayValue(typeConfig)) {
|
|
462
267
|
const defaultEngineTypes = this._engineCore.getDefaultTypes();
|
|
268
|
+
const generateRoutes = await modules.ModuleHelper.getModuleEntry(module, method);
|
|
463
269
|
for (let i = 0; i < typeConfig.length; i++) {
|
|
464
270
|
const socketPath = typeConfig[i].socketPath;
|
|
465
271
|
if (core.Is.string(socketPath)) {
|
|
@@ -476,192 +282,139 @@ class EngineServer {
|
|
|
476
282
|
* @internal
|
|
477
283
|
*/
|
|
478
284
|
addServerTypeInitialisers() {
|
|
479
|
-
this._engineCore.
|
|
480
|
-
this._engineCore.addTypeInitialiser("
|
|
481
|
-
this._engineCore.addTypeInitialiser("
|
|
482
|
-
this._engineCore.addTypeInitialiser("
|
|
483
|
-
this._engineCore.addTypeInitialiser("
|
|
285
|
+
const coreConfig = this._engineCore.getConfig();
|
|
286
|
+
this._engineCore.addTypeInitialiser("authenticationComponent", coreConfig.types.authenticationComponent, "@twin.org/engine-server-types", "initialiseAuthenticationComponent");
|
|
287
|
+
this._engineCore.addTypeInitialiser("informationComponent", coreConfig.types.informationComponent, "@twin.org/engine-server-types", "initialiseInformationComponent");
|
|
288
|
+
this._engineCore.addTypeInitialiser("restRouteProcessor", coreConfig.types.restRouteProcessor, "@twin.org/engine-server-types", "initialiseRestRouteProcessorComponent");
|
|
289
|
+
this._engineCore.addTypeInitialiser("socketRouteProcessor", coreConfig.types.socketRouteProcessor, "@twin.org/engine-server-types", "initialiseSocketRouteProcessorComponent");
|
|
290
|
+
this._engineCore.addTypeInitialiser("mimeTypeProcessor", coreConfig.types.mimeTypeProcessor, "@twin.org/engine-server-types", "initialiseMimeTypeProcessorComponent");
|
|
484
291
|
}
|
|
485
292
|
/**
|
|
486
293
|
* Add the server REST route generators.
|
|
487
294
|
* @internal
|
|
488
295
|
*/
|
|
489
296
|
addServerRestRouteGenerators() {
|
|
490
|
-
this.addRestRouteGenerator("informationComponent", this._config.informationComponent, apiService.generateRestRoutesInformation);
|
|
491
|
-
this.addRestRouteGenerator("authenticationComponent", this._config.authenticationComponent, apiAuthEntityStorageService.generateRestRoutesAuthentication);
|
|
492
297
|
const coreConfig = this._engineCore.getConfig();
|
|
493
|
-
this.addRestRouteGenerator("
|
|
494
|
-
this.addRestRouteGenerator("
|
|
495
|
-
this.addRestRouteGenerator("
|
|
496
|
-
this.addRestRouteGenerator("
|
|
497
|
-
this.addRestRouteGenerator("
|
|
498
|
-
this.addRestRouteGenerator("
|
|
499
|
-
this.addRestRouteGenerator("
|
|
500
|
-
this.addRestRouteGenerator("
|
|
501
|
-
this.addRestRouteGenerator("
|
|
502
|
-
this.addRestRouteGenerator("
|
|
298
|
+
this.addRestRouteGenerator("informationComponent", coreConfig.types.informationComponent, "@twin.org/api-service", "generateRestRoutesInformation");
|
|
299
|
+
this.addRestRouteGenerator("authenticationComponent", coreConfig.types.authenticationComponent, "@twin.org/api-auth-entity-storage-service", "generateRestRoutesAuthentication");
|
|
300
|
+
this.addRestRouteGenerator("loggingComponent", coreConfig.types.loggingComponent, "@twin.org/logging-service", "generateRestRoutesLogging");
|
|
301
|
+
this.addRestRouteGenerator("telemetryComponent", coreConfig.types.telemetryComponent, "@twin.org/telemetry-service", "generateRestRoutesTelemetry");
|
|
302
|
+
this.addRestRouteGenerator("blobStorageComponent", coreConfig.types.blobStorageComponent, "@twin.org/blob-storage-service", "generateRestRoutesBlobStorage");
|
|
303
|
+
this.addRestRouteGenerator("identityComponent", coreConfig.types.identityComponent, "@twin.org/identity-service", "generateRestRoutesIdentity");
|
|
304
|
+
this.addRestRouteGenerator("identityResolverComponent", coreConfig.types.identityResolverComponent, "@twin.org/identity-service", "generateRestRoutesIdentityResolver");
|
|
305
|
+
this.addRestRouteGenerator("identityProfileComponent", coreConfig.types.identityProfileComponent, "@twin.org/identity-service", "generateRestRoutesIdentityProfile");
|
|
306
|
+
this.addRestRouteGenerator("nftComponent", coreConfig.types.nftComponent, "@twin.org/nft-service", "generateRestRoutesNft");
|
|
307
|
+
this.addRestRouteGenerator("verifiableStorageComponent", coreConfig.types.verifiableStorageComponent, "@twin.org/verifiable-storage-service", "generateRestRoutesVerifiableStorage");
|
|
308
|
+
this.addRestRouteGenerator("attestationComponent", coreConfig.types.attestationComponent, "@twin.org/attestation-service", "generateRestRoutesAttestation");
|
|
309
|
+
this.addRestRouteGenerator("immutableProofComponent", coreConfig.types.immutableProofComponent, "@twin.org/immutable-proof-service", "generateRestRoutesImmutableProof");
|
|
310
|
+
this.addRestRouteGenerator("auditableItemGraphComponent", coreConfig.types.auditableItemGraphComponent, "@twin.org/auditable-item-graph-service", "generateRestRoutesAuditableItemGraph");
|
|
311
|
+
this.addRestRouteGenerator("auditableItemStreamComponent", coreConfig.types.auditableItemStreamComponent, "@twin.org/auditable-item-stream-service", "generateRestRoutesAuditableItemStream");
|
|
312
|
+
this.addRestRouteGenerator("entityStorageComponent", coreConfig.types.entityStorageComponent, "@twin.org/entity-storage-service", "generateRestRoutesEntityStorage");
|
|
313
|
+
this.addRestRouteGenerator("dataProcessingComponent", coreConfig.types.dataProcessingComponent, "@twin.org/data-processing-service", "generateRestRoutesDataProcessing");
|
|
314
|
+
this.addRestRouteGenerator("documentManagementComponent", coreConfig.types.documentManagementComponent, "@twin.org/document-management-service", "generateRestRoutesDocumentManagement");
|
|
315
|
+
this.addRestRouteGenerator("federatedCatalogueComponent", coreConfig.types.federatedCatalogueComponent, "@twin.org/federated-catalogue-service", "generateRestRoutesFederatedCatalogue");
|
|
316
|
+
this.addRestRouteGenerator("rightsManagementComponent", coreConfig.types.rightsManagementComponent, "@twin.org/rights-management-service", "generateRestRoutesRightsManagement");
|
|
503
317
|
}
|
|
504
318
|
/**
|
|
505
319
|
* Add the server socket route generators.
|
|
506
320
|
* @internal
|
|
507
321
|
*/
|
|
508
322
|
addServerSocketRouteGenerators() {
|
|
509
|
-
|
|
510
|
-
|
|
323
|
+
const coreConfig = this._engineCore.getConfig();
|
|
324
|
+
this.addSocketRouteGenerator("eventBusComponent", coreConfig.types.eventBusComponent, "@twin.org/event-bus-service", "generateSocketRoutesEventBus");
|
|
511
325
|
}
|
|
512
326
|
}
|
|
513
327
|
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
* @param envVars The environment variables.
|
|
517
|
-
* @param coreEngineConfig The core engine config.
|
|
518
|
-
* @param serverInfo The server information.
|
|
519
|
-
* @returns The the config for the core and the server.
|
|
520
|
-
*/
|
|
521
|
-
function buildEngineServerConfiguration(envVars, coreEngineConfig, serverInfo) {
|
|
522
|
-
envVars.adminUsername ??= "admin@node";
|
|
523
|
-
envVars.authSigningKeyId ??= "auth-signing";
|
|
524
|
-
const webServerOptions = {
|
|
525
|
-
port: core.Coerce.number(envVars.port),
|
|
526
|
-
host: core.Coerce.string(envVars.host),
|
|
527
|
-
methods: core.Is.stringValue(envVars.httpMethods)
|
|
528
|
-
? envVars.httpMethods.split(",")
|
|
529
|
-
: undefined,
|
|
530
|
-
allowedHeaders: core.Is.stringValue(envVars.httpAllowedHeaders)
|
|
531
|
-
? envVars.httpAllowedHeaders.split(",")
|
|
532
|
-
: undefined,
|
|
533
|
-
exposedHeaders: core.Is.stringValue(envVars.httpExposedHeaders)
|
|
534
|
-
? envVars.httpExposedHeaders.split(",")
|
|
535
|
-
: undefined,
|
|
536
|
-
corsOrigins: core.Is.stringValue(envVars.corsOrigins) ? envVars.corsOrigins.split(",") : undefined
|
|
537
|
-
};
|
|
538
|
-
const authProcessorType = envVars.authProcessorType;
|
|
539
|
-
const serverConfig = {
|
|
540
|
-
web: webServerOptions,
|
|
541
|
-
informationComponent: [
|
|
542
|
-
{
|
|
543
|
-
type: engineModels.InformationComponentType.Service,
|
|
544
|
-
options: {
|
|
545
|
-
config: {
|
|
546
|
-
serverInfo
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
],
|
|
551
|
-
restRouteProcessor: []
|
|
552
|
-
};
|
|
553
|
-
serverConfig.restRouteProcessor ??= [];
|
|
554
|
-
serverConfig.socketRouteProcessor ??= [];
|
|
555
|
-
serverConfig.restRouteProcessor.push({
|
|
556
|
-
type: engineModels.RestRouteProcessorType.NodeIdentity
|
|
557
|
-
});
|
|
558
|
-
serverConfig.socketRouteProcessor.push({
|
|
559
|
-
type: engineModels.SocketRouteProcessorType.NodeIdentity
|
|
560
|
-
});
|
|
561
|
-
if (!coreEngineConfig.silent) {
|
|
562
|
-
serverConfig.restRouteProcessor.push({
|
|
563
|
-
type: engineModels.RestRouteProcessorType.Logging,
|
|
564
|
-
options: {
|
|
565
|
-
config: {
|
|
566
|
-
includeBody: coreEngineConfig.debug
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
});
|
|
570
|
-
serverConfig.socketRouteProcessor.push({
|
|
571
|
-
type: engineModels.SocketRouteProcessorType.Logging,
|
|
572
|
-
options: {
|
|
573
|
-
config: {
|
|
574
|
-
includeBody: coreEngineConfig.debug
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
});
|
|
578
|
-
}
|
|
579
|
-
serverConfig.restRouteProcessor.push({
|
|
580
|
-
type: engineModels.RestRouteProcessorType.RestRoute,
|
|
581
|
-
options: {
|
|
582
|
-
config: {
|
|
583
|
-
includeErrorStack: coreEngineConfig.debug
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
});
|
|
587
|
-
serverConfig.socketRouteProcessor.push({
|
|
588
|
-
type: engineModels.SocketRouteProcessorType.SocketRoute,
|
|
589
|
-
options: {
|
|
590
|
-
config: {
|
|
591
|
-
includeErrorStack: coreEngineConfig.debug
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
});
|
|
595
|
-
if (authProcessorType === engineModels.AuthenticationComponentType.EntityStorage) {
|
|
596
|
-
serverConfig.authenticationComponent ??= [];
|
|
597
|
-
serverConfig.authenticationComponent.push({
|
|
598
|
-
type: engineModels.AuthenticationComponentType.EntityStorage,
|
|
599
|
-
options: {
|
|
600
|
-
config: {
|
|
601
|
-
signingKeyName: envVars.authSigningKeyId
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
});
|
|
605
|
-
serverConfig.restRouteProcessor.push({
|
|
606
|
-
type: engineModels.RestRouteProcessorType.AuthHeader,
|
|
607
|
-
options: {
|
|
608
|
-
config: {
|
|
609
|
-
signingKeyName: envVars.authSigningKeyId
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
});
|
|
613
|
-
serverConfig.socketRouteProcessor.push({
|
|
614
|
-
type: engineModels.SocketRouteProcessorType.AuthHeader,
|
|
615
|
-
options: {
|
|
616
|
-
config: {
|
|
617
|
-
signingKeyName: envVars.authSigningKeyId
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
});
|
|
621
|
-
}
|
|
622
|
-
addRestPaths(coreEngineConfig, serverConfig);
|
|
623
|
-
return serverConfig;
|
|
624
|
-
}
|
|
328
|
+
// Copyright 2024 IOTA Stiftung.
|
|
329
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
625
330
|
/**
|
|
626
331
|
* Adds the rest paths to the server config.
|
|
627
|
-
* @param coreEngineConfig The core engine config.
|
|
628
332
|
* @param serverConfig The server config.
|
|
629
333
|
*/
|
|
630
|
-
function
|
|
631
|
-
if (core.Is.arrayValue(serverConfig.informationComponent)) {
|
|
632
|
-
serverConfig.informationComponent[0].restPath = "";
|
|
334
|
+
function addDefaultRestPaths(serverConfig) {
|
|
335
|
+
if (core.Is.arrayValue(serverConfig.types.informationComponent)) {
|
|
336
|
+
serverConfig.types.informationComponent[0].restPath = "";
|
|
337
|
+
}
|
|
338
|
+
if (core.Is.arrayValue(serverConfig.types.authenticationComponent) &&
|
|
339
|
+
!core.Is.stringValue(serverConfig.types.authenticationComponent[0].restPath)) {
|
|
340
|
+
serverConfig.types.authenticationComponent[0].restPath = "/authentication";
|
|
341
|
+
}
|
|
342
|
+
if (core.Is.arrayValue(serverConfig.types.blobStorageComponent) &&
|
|
343
|
+
!core.Is.stringValue(serverConfig.types.blobStorageComponent[0].restPath)) {
|
|
344
|
+
serverConfig.types.blobStorageComponent[0].restPath = "/blob";
|
|
345
|
+
}
|
|
346
|
+
if (core.Is.arrayValue(serverConfig.types.loggingComponent) &&
|
|
347
|
+
!core.Is.stringValue(serverConfig.types.loggingComponent[0].restPath)) {
|
|
348
|
+
serverConfig.types.loggingComponent[0].restPath = "/logging";
|
|
349
|
+
}
|
|
350
|
+
if (core.Is.arrayValue(serverConfig.types.telemetryComponent) &&
|
|
351
|
+
!core.Is.stringValue(serverConfig.types.telemetryComponent[0].restPath)) {
|
|
352
|
+
serverConfig.types.telemetryComponent[0].restPath = "/telemetry";
|
|
633
353
|
}
|
|
634
|
-
if (core.Is.arrayValue(serverConfig.
|
|
635
|
-
serverConfig.
|
|
354
|
+
if (core.Is.arrayValue(serverConfig.types.identityComponent) &&
|
|
355
|
+
!core.Is.stringValue(serverConfig.types.identityComponent[0].restPath)) {
|
|
356
|
+
serverConfig.types.identityComponent[0].restPath = "/identity";
|
|
636
357
|
}
|
|
637
|
-
if (core.Is.arrayValue(
|
|
638
|
-
|
|
358
|
+
if (core.Is.arrayValue(serverConfig.types.identityResolverComponent) &&
|
|
359
|
+
!core.Is.stringValue(serverConfig.types.identityResolverComponent[0].restPath)) {
|
|
360
|
+
serverConfig.types.identityResolverComponent[0].restPath = "/identity";
|
|
639
361
|
}
|
|
640
|
-
if (core.Is.arrayValue(
|
|
641
|
-
|
|
362
|
+
if (core.Is.arrayValue(serverConfig.types.identityProfileComponent) &&
|
|
363
|
+
!core.Is.stringValue(serverConfig.types.identityProfileComponent[0].restPath)) {
|
|
364
|
+
serverConfig.types.identityProfileComponent[0].restPath = "/identity/profile";
|
|
642
365
|
}
|
|
643
|
-
if (core.Is.arrayValue(
|
|
644
|
-
|
|
366
|
+
if (core.Is.arrayValue(serverConfig.types.nftComponent) &&
|
|
367
|
+
!core.Is.stringValue(serverConfig.types.nftComponent[0].restPath)) {
|
|
368
|
+
serverConfig.types.nftComponent[0].restPath = "/nft";
|
|
645
369
|
}
|
|
646
|
-
if (core.Is.arrayValue(
|
|
647
|
-
|
|
370
|
+
if (core.Is.arrayValue(serverConfig.types.verifiableStorageComponent) &&
|
|
371
|
+
!core.Is.stringValue(serverConfig.types.verifiableStorageComponent[0].restPath)) {
|
|
372
|
+
serverConfig.types.verifiableStorageComponent[0].restPath = "/verifiable";
|
|
648
373
|
}
|
|
649
|
-
if (core.Is.arrayValue(
|
|
650
|
-
|
|
374
|
+
if (core.Is.arrayValue(serverConfig.types.immutableProofComponent) &&
|
|
375
|
+
!core.Is.stringValue(serverConfig.types.immutableProofComponent[0].restPath)) {
|
|
376
|
+
serverConfig.types.immutableProofComponent[0].restPath = "/immutable-proof";
|
|
651
377
|
}
|
|
652
|
-
if (core.Is.arrayValue(
|
|
653
|
-
|
|
378
|
+
if (core.Is.arrayValue(serverConfig.types.attestationComponent) &&
|
|
379
|
+
!core.Is.stringValue(serverConfig.types.attestationComponent[0].restPath)) {
|
|
380
|
+
serverConfig.types.attestationComponent[0].restPath = "/attestation";
|
|
654
381
|
}
|
|
655
|
-
if (core.Is.arrayValue(
|
|
656
|
-
|
|
382
|
+
if (core.Is.arrayValue(serverConfig.types.auditableItemGraphComponent) &&
|
|
383
|
+
!core.Is.stringValue(serverConfig.types.auditableItemGraphComponent[0].restPath)) {
|
|
384
|
+
serverConfig.types.auditableItemGraphComponent[0].restPath = "/aig";
|
|
657
385
|
}
|
|
658
|
-
if (core.Is.arrayValue(
|
|
659
|
-
|
|
386
|
+
if (core.Is.arrayValue(serverConfig.types.auditableItemStreamComponent) &&
|
|
387
|
+
!core.Is.stringValue(serverConfig.types.auditableItemStreamComponent[0].restPath)) {
|
|
388
|
+
serverConfig.types.auditableItemStreamComponent[0].restPath = "/ais";
|
|
660
389
|
}
|
|
661
|
-
if (core.Is.arrayValue(
|
|
662
|
-
|
|
390
|
+
if (core.Is.arrayValue(serverConfig.types.dataProcessingComponent) &&
|
|
391
|
+
!core.Is.stringValue(serverConfig.types.dataProcessingComponent[0].restPath)) {
|
|
392
|
+
serverConfig.types.dataProcessingComponent[0].restPath = "/data-processing";
|
|
393
|
+
}
|
|
394
|
+
if (core.Is.arrayValue(serverConfig.types.documentManagementComponent) &&
|
|
395
|
+
!core.Is.stringValue(serverConfig.types.documentManagementComponent[0].restPath)) {
|
|
396
|
+
serverConfig.types.documentManagementComponent[0].restPath = "/documents";
|
|
397
|
+
}
|
|
398
|
+
if (core.Is.arrayValue(serverConfig.types.federatedCatalogueComponent) &&
|
|
399
|
+
!core.Is.stringValue(serverConfig.types.federatedCatalogueComponent[0].restPath)) {
|
|
400
|
+
serverConfig.types.federatedCatalogueComponent[0].restPath = "/federated-catalogue";
|
|
401
|
+
}
|
|
402
|
+
if (core.Is.arrayValue(serverConfig.types.rightsManagementComponent) &&
|
|
403
|
+
!core.Is.stringValue(serverConfig.types.rightsManagementComponent[0].restPath)) {
|
|
404
|
+
serverConfig.types.rightsManagementComponent[0].restPath = "/rights-management";
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Adds the socket paths to the server config.
|
|
409
|
+
* @param serverConfig The server config.
|
|
410
|
+
*/
|
|
411
|
+
function addDefaultSocketPaths(serverConfig) {
|
|
412
|
+
if (core.Is.arrayValue(serverConfig.types.eventBusComponent) &&
|
|
413
|
+
!core.Is.stringValue(serverConfig.types.eventBusComponent[0].socketPath)) {
|
|
414
|
+
serverConfig.types.eventBusComponent[0].socketPath = "event-bus";
|
|
663
415
|
}
|
|
664
416
|
}
|
|
665
417
|
|
|
666
418
|
exports.EngineServer = EngineServer;
|
|
667
|
-
exports.
|
|
419
|
+
exports.addDefaultRestPaths = addDefaultRestPaths;
|
|
420
|
+
exports.addDefaultSocketPaths = addDefaultSocketPaths;
|