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