@twin.org/engine-server 0.0.1-next.67 → 0.0.1-next.69

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.
@@ -39,6 +39,16 @@ class EngineServer {
39
39
  * @internal
40
40
  */
41
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;
42
52
  /**
43
53
  * Create a new instance of EngineServer.
44
54
  * @param options The options for the engine.
@@ -50,6 +60,8 @@ class EngineServer {
50
60
  this._engineCore = options.engineCore;
51
61
  this._restRouteGenerators = [];
52
62
  this._socketRouteGenerators = [];
63
+ this._restRoutes = [];
64
+ this._socketRoutes = [];
53
65
  const coreConfig = this._engineCore.getConfig();
54
66
  if (!core.Is.arrayValue(coreConfig.types.restRouteProcessor)) {
55
67
  coreConfig.types.restRouteProcessor = [];
@@ -131,6 +143,20 @@ class EngineServer {
131
143
  });
132
144
  }
133
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
+ }
134
160
  /**
135
161
  * Start the engine server.
136
162
  * @returns True if the start was successful.
@@ -158,8 +184,8 @@ class EngineServer {
158
184
  * @internal
159
185
  */
160
186
  async startWebServer() {
161
- const restRoutes = await this.buildRestRoutes();
162
- const socketRoutes = await this.buildSocketRoutes();
187
+ this._restRoutes = await this.buildRestRoutes();
188
+ this._socketRoutes = await this.buildSocketRoutes();
163
189
  const restRouteProcessors = apiModels.RestRouteProcessorFactory.names().map(n => apiModels.RestRouteProcessorFactory.get(n));
164
190
  const socketRouteProcessors = apiModels.SocketRouteProcessorFactory.names().map(n => apiModels.SocketRouteProcessorFactory.get(n));
165
191
  const mimeTypeProcessors = apiModels.MimeTypeProcessorFactory.names().map(n => apiModels.MimeTypeProcessorFactory.get(n));
@@ -170,7 +196,7 @@ class EngineServer {
170
196
  loggingConnectorType: this._loggingConnectorType,
171
197
  mimeTypeProcessors
172
198
  });
173
- await this._webServer.build(restRouteProcessors, restRoutes, socketRouteProcessors, socketRoutes, coreConfig.web);
199
+ await this._webServer.build(restRouteProcessors, this._restRoutes, socketRouteProcessors, this._socketRoutes, coreConfig.web);
174
200
  await this._webServer.start();
175
201
  }
176
202
  /**
@@ -416,16 +442,15 @@ function buildEngineServerConfiguration(envVars, coreEngineConfig, serverInfo, o
416
442
  }
417
443
  });
418
444
  }
419
- addRestPaths(coreEngineConfig, serverConfig);
420
- addSocketPaths(coreEngineConfig);
445
+ addDefaultRestPaths(serverConfig);
446
+ addDefaultSocketPaths(serverConfig);
421
447
  return serverConfig;
422
448
  }
423
449
  /**
424
450
  * Adds the rest paths to the server config.
425
- * @param coreEngineConfig The core engine config.
426
451
  * @param serverConfig The server config.
427
452
  */
428
- function addRestPaths(coreEngineConfig, serverConfig) {
453
+ function addDefaultRestPaths(serverConfig) {
429
454
  if (core.Is.arrayValue(serverConfig.types.informationComponent)) {
430
455
  serverConfig.types.informationComponent[0].restPath = "";
431
456
  }
@@ -433,74 +458,75 @@ function addRestPaths(coreEngineConfig, serverConfig) {
433
458
  !core.Is.stringValue(serverConfig.types.authenticationComponent[0].restPath)) {
434
459
  serverConfig.types.authenticationComponent[0].restPath = "authentication";
435
460
  }
436
- if (core.Is.arrayValue(coreEngineConfig.types.blobStorageComponent) &&
437
- !core.Is.stringValue(coreEngineConfig.types.blobStorageComponent[0].restPath)) {
438
- coreEngineConfig.types.blobStorageComponent[0].restPath = "blob";
461
+ if (core.Is.arrayValue(serverConfig.types.blobStorageComponent) &&
462
+ !core.Is.stringValue(serverConfig.types.blobStorageComponent[0].restPath)) {
463
+ serverConfig.types.blobStorageComponent[0].restPath = "blob";
439
464
  }
440
- if (core.Is.arrayValue(coreEngineConfig.types.loggingComponent) &&
441
- !core.Is.stringValue(coreEngineConfig.types.loggingComponent[0].restPath)) {
442
- coreEngineConfig.types.loggingComponent[0].restPath = "logging";
465
+ if (core.Is.arrayValue(serverConfig.types.loggingComponent) &&
466
+ !core.Is.stringValue(serverConfig.types.loggingComponent[0].restPath)) {
467
+ serverConfig.types.loggingComponent[0].restPath = "logging";
443
468
  }
444
- if (core.Is.arrayValue(coreEngineConfig.types.telemetryComponent) &&
445
- !core.Is.stringValue(coreEngineConfig.types.telemetryComponent[0].restPath)) {
446
- coreEngineConfig.types.telemetryComponent[0].restPath = "telemetry";
469
+ if (core.Is.arrayValue(serverConfig.types.telemetryComponent) &&
470
+ !core.Is.stringValue(serverConfig.types.telemetryComponent[0].restPath)) {
471
+ serverConfig.types.telemetryComponent[0].restPath = "telemetry";
447
472
  }
448
- if (core.Is.arrayValue(coreEngineConfig.types.identityComponent) &&
449
- !core.Is.stringValue(coreEngineConfig.types.identityComponent[0].restPath)) {
450
- coreEngineConfig.types.identityComponent[0].restPath = "identity";
473
+ if (core.Is.arrayValue(serverConfig.types.identityComponent) &&
474
+ !core.Is.stringValue(serverConfig.types.identityComponent[0].restPath)) {
475
+ serverConfig.types.identityComponent[0].restPath = "identity";
451
476
  }
452
- if (core.Is.arrayValue(coreEngineConfig.types.identityResolverComponent) &&
453
- !core.Is.stringValue(coreEngineConfig.types.identityResolverComponent[0].restPath)) {
454
- coreEngineConfig.types.identityResolverComponent[0].restPath = "identity";
477
+ if (core.Is.arrayValue(serverConfig.types.identityResolverComponent) &&
478
+ !core.Is.stringValue(serverConfig.types.identityResolverComponent[0].restPath)) {
479
+ serverConfig.types.identityResolverComponent[0].restPath = "identity";
455
480
  }
456
- if (core.Is.arrayValue(coreEngineConfig.types.identityProfileComponent) &&
457
- !core.Is.stringValue(coreEngineConfig.types.identityProfileComponent[0].restPath)) {
458
- coreEngineConfig.types.identityProfileComponent[0].restPath = "identity/profile";
481
+ if (core.Is.arrayValue(serverConfig.types.identityProfileComponent) &&
482
+ !core.Is.stringValue(serverConfig.types.identityProfileComponent[0].restPath)) {
483
+ serverConfig.types.identityProfileComponent[0].restPath = "identity/profile";
459
484
  }
460
- if (core.Is.arrayValue(coreEngineConfig.types.nftComponent) &&
461
- !core.Is.stringValue(coreEngineConfig.types.nftComponent[0].restPath)) {
462
- coreEngineConfig.types.nftComponent[0].restPath = "nft";
485
+ if (core.Is.arrayValue(serverConfig.types.nftComponent) &&
486
+ !core.Is.stringValue(serverConfig.types.nftComponent[0].restPath)) {
487
+ serverConfig.types.nftComponent[0].restPath = "nft";
463
488
  }
464
- if (core.Is.arrayValue(coreEngineConfig.types.verifiableStorageComponent) &&
465
- !core.Is.stringValue(coreEngineConfig.types.verifiableStorageComponent[0].restPath)) {
466
- coreEngineConfig.types.verifiableStorageComponent[0].restPath = "verifiable";
489
+ if (core.Is.arrayValue(serverConfig.types.verifiableStorageComponent) &&
490
+ !core.Is.stringValue(serverConfig.types.verifiableStorageComponent[0].restPath)) {
491
+ serverConfig.types.verifiableStorageComponent[0].restPath = "verifiable";
467
492
  }
468
- if (core.Is.arrayValue(coreEngineConfig.types.immutableProofComponent) &&
469
- !core.Is.stringValue(coreEngineConfig.types.immutableProofComponent[0].restPath)) {
470
- coreEngineConfig.types.immutableProofComponent[0].restPath = "immutable-proof";
493
+ if (core.Is.arrayValue(serverConfig.types.immutableProofComponent) &&
494
+ !core.Is.stringValue(serverConfig.types.immutableProofComponent[0].restPath)) {
495
+ serverConfig.types.immutableProofComponent[0].restPath = "immutable-proof";
471
496
  }
472
- if (core.Is.arrayValue(coreEngineConfig.types.attestationComponent) &&
473
- !core.Is.stringValue(coreEngineConfig.types.attestationComponent[0].restPath)) {
474
- coreEngineConfig.types.attestationComponent[0].restPath = "attestation";
497
+ if (core.Is.arrayValue(serverConfig.types.attestationComponent) &&
498
+ !core.Is.stringValue(serverConfig.types.attestationComponent[0].restPath)) {
499
+ serverConfig.types.attestationComponent[0].restPath = "attestation";
475
500
  }
476
- if (core.Is.arrayValue(coreEngineConfig.types.auditableItemGraphComponent) &&
477
- !core.Is.stringValue(coreEngineConfig.types.auditableItemGraphComponent[0].restPath)) {
478
- coreEngineConfig.types.auditableItemGraphComponent[0].restPath = "aig";
501
+ if (core.Is.arrayValue(serverConfig.types.auditableItemGraphComponent) &&
502
+ !core.Is.stringValue(serverConfig.types.auditableItemGraphComponent[0].restPath)) {
503
+ serverConfig.types.auditableItemGraphComponent[0].restPath = "aig";
479
504
  }
480
- if (core.Is.arrayValue(coreEngineConfig.types.auditableItemStreamComponent) &&
481
- !core.Is.stringValue(coreEngineConfig.types.auditableItemStreamComponent[0].restPath)) {
482
- coreEngineConfig.types.auditableItemStreamComponent[0].restPath = "ais";
505
+ if (core.Is.arrayValue(serverConfig.types.auditableItemStreamComponent) &&
506
+ !core.Is.stringValue(serverConfig.types.auditableItemStreamComponent[0].restPath)) {
507
+ serverConfig.types.auditableItemStreamComponent[0].restPath = "ais";
483
508
  }
484
- if (core.Is.arrayValue(coreEngineConfig.types.dataProcessingComponent) &&
485
- !core.Is.stringValue(coreEngineConfig.types.dataProcessingComponent[0].restPath)) {
486
- coreEngineConfig.types.dataProcessingComponent[0].restPath = "data-processing";
509
+ if (core.Is.arrayValue(serverConfig.types.dataProcessingComponent) &&
510
+ !core.Is.stringValue(serverConfig.types.dataProcessingComponent[0].restPath)) {
511
+ serverConfig.types.dataProcessingComponent[0].restPath = "data-processing";
487
512
  }
488
- if (core.Is.arrayValue(coreEngineConfig.types.documentManagementComponent) &&
489
- !core.Is.stringValue(coreEngineConfig.types.documentManagementComponent[0].restPath)) {
490
- coreEngineConfig.types.documentManagementComponent[0].restPath = "document-management";
513
+ if (core.Is.arrayValue(serverConfig.types.documentManagementComponent) &&
514
+ !core.Is.stringValue(serverConfig.types.documentManagementComponent[0].restPath)) {
515
+ serverConfig.types.documentManagementComponent[0].restPath = "documents";
491
516
  }
492
517
  }
493
518
  /**
494
519
  * Adds the socket paths to the server config.
495
- * @param coreEngineConfig The core engine config.
496
520
  * @param serverConfig The server config.
497
521
  */
498
- function addSocketPaths(coreEngineConfig, serverConfig) {
499
- if (core.Is.arrayValue(coreEngineConfig.types.eventBusComponent) &&
500
- !core.Is.stringValue(coreEngineConfig.types.eventBusComponent[0].socketPath)) {
501
- coreEngineConfig.types.eventBusComponent[0].socketPath = "event-bus";
522
+ function addDefaultSocketPaths(serverConfig) {
523
+ if (core.Is.arrayValue(serverConfig.types.eventBusComponent) &&
524
+ !core.Is.stringValue(serverConfig.types.eventBusComponent[0].socketPath)) {
525
+ serverConfig.types.eventBusComponent[0].socketPath = "event-bus";
502
526
  }
503
527
  }
504
528
 
505
529
  exports.EngineServer = EngineServer;
530
+ exports.addDefaultRestPaths = addDefaultRestPaths;
531
+ exports.addDefaultSocketPaths = addDefaultSocketPaths;
506
532
  exports.buildEngineServerConfiguration = buildEngineServerConfiguration;
@@ -37,6 +37,16 @@ class EngineServer {
37
37
  * @internal
38
38
  */
39
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;
40
50
  /**
41
51
  * Create a new instance of EngineServer.
42
52
  * @param options The options for the engine.
@@ -48,6 +58,8 @@ class EngineServer {
48
58
  this._engineCore = options.engineCore;
49
59
  this._restRouteGenerators = [];
50
60
  this._socketRouteGenerators = [];
61
+ this._restRoutes = [];
62
+ this._socketRoutes = [];
51
63
  const coreConfig = this._engineCore.getConfig();
52
64
  if (!Is.arrayValue(coreConfig.types.restRouteProcessor)) {
53
65
  coreConfig.types.restRouteProcessor = [];
@@ -129,6 +141,20 @@ class EngineServer {
129
141
  });
130
142
  }
131
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
+ }
132
158
  /**
133
159
  * Start the engine server.
134
160
  * @returns True if the start was successful.
@@ -156,8 +182,8 @@ class EngineServer {
156
182
  * @internal
157
183
  */
158
184
  async startWebServer() {
159
- const restRoutes = await this.buildRestRoutes();
160
- const socketRoutes = await this.buildSocketRoutes();
185
+ this._restRoutes = await this.buildRestRoutes();
186
+ this._socketRoutes = await this.buildSocketRoutes();
161
187
  const restRouteProcessors = RestRouteProcessorFactory.names().map(n => RestRouteProcessorFactory.get(n));
162
188
  const socketRouteProcessors = SocketRouteProcessorFactory.names().map(n => SocketRouteProcessorFactory.get(n));
163
189
  const mimeTypeProcessors = MimeTypeProcessorFactory.names().map(n => MimeTypeProcessorFactory.get(n));
@@ -168,7 +194,7 @@ class EngineServer {
168
194
  loggingConnectorType: this._loggingConnectorType,
169
195
  mimeTypeProcessors
170
196
  });
171
- await this._webServer.build(restRouteProcessors, restRoutes, socketRouteProcessors, socketRoutes, coreConfig.web);
197
+ await this._webServer.build(restRouteProcessors, this._restRoutes, socketRouteProcessors, this._socketRoutes, coreConfig.web);
172
198
  await this._webServer.start();
173
199
  }
174
200
  /**
@@ -414,16 +440,15 @@ function buildEngineServerConfiguration(envVars, coreEngineConfig, serverInfo, o
414
440
  }
415
441
  });
416
442
  }
417
- addRestPaths(coreEngineConfig, serverConfig);
418
- addSocketPaths(coreEngineConfig);
443
+ addDefaultRestPaths(serverConfig);
444
+ addDefaultSocketPaths(serverConfig);
419
445
  return serverConfig;
420
446
  }
421
447
  /**
422
448
  * Adds the rest paths to the server config.
423
- * @param coreEngineConfig The core engine config.
424
449
  * @param serverConfig The server config.
425
450
  */
426
- function addRestPaths(coreEngineConfig, serverConfig) {
451
+ function addDefaultRestPaths(serverConfig) {
427
452
  if (Is.arrayValue(serverConfig.types.informationComponent)) {
428
453
  serverConfig.types.informationComponent[0].restPath = "";
429
454
  }
@@ -431,73 +456,72 @@ function addRestPaths(coreEngineConfig, serverConfig) {
431
456
  !Is.stringValue(serverConfig.types.authenticationComponent[0].restPath)) {
432
457
  serverConfig.types.authenticationComponent[0].restPath = "authentication";
433
458
  }
434
- if (Is.arrayValue(coreEngineConfig.types.blobStorageComponent) &&
435
- !Is.stringValue(coreEngineConfig.types.blobStorageComponent[0].restPath)) {
436
- coreEngineConfig.types.blobStorageComponent[0].restPath = "blob";
459
+ if (Is.arrayValue(serverConfig.types.blobStorageComponent) &&
460
+ !Is.stringValue(serverConfig.types.blobStorageComponent[0].restPath)) {
461
+ serverConfig.types.blobStorageComponent[0].restPath = "blob";
437
462
  }
438
- if (Is.arrayValue(coreEngineConfig.types.loggingComponent) &&
439
- !Is.stringValue(coreEngineConfig.types.loggingComponent[0].restPath)) {
440
- coreEngineConfig.types.loggingComponent[0].restPath = "logging";
463
+ if (Is.arrayValue(serverConfig.types.loggingComponent) &&
464
+ !Is.stringValue(serverConfig.types.loggingComponent[0].restPath)) {
465
+ serverConfig.types.loggingComponent[0].restPath = "logging";
441
466
  }
442
- if (Is.arrayValue(coreEngineConfig.types.telemetryComponent) &&
443
- !Is.stringValue(coreEngineConfig.types.telemetryComponent[0].restPath)) {
444
- coreEngineConfig.types.telemetryComponent[0].restPath = "telemetry";
467
+ if (Is.arrayValue(serverConfig.types.telemetryComponent) &&
468
+ !Is.stringValue(serverConfig.types.telemetryComponent[0].restPath)) {
469
+ serverConfig.types.telemetryComponent[0].restPath = "telemetry";
445
470
  }
446
- if (Is.arrayValue(coreEngineConfig.types.identityComponent) &&
447
- !Is.stringValue(coreEngineConfig.types.identityComponent[0].restPath)) {
448
- coreEngineConfig.types.identityComponent[0].restPath = "identity";
471
+ if (Is.arrayValue(serverConfig.types.identityComponent) &&
472
+ !Is.stringValue(serverConfig.types.identityComponent[0].restPath)) {
473
+ serverConfig.types.identityComponent[0].restPath = "identity";
449
474
  }
450
- if (Is.arrayValue(coreEngineConfig.types.identityResolverComponent) &&
451
- !Is.stringValue(coreEngineConfig.types.identityResolverComponent[0].restPath)) {
452
- coreEngineConfig.types.identityResolverComponent[0].restPath = "identity";
475
+ if (Is.arrayValue(serverConfig.types.identityResolverComponent) &&
476
+ !Is.stringValue(serverConfig.types.identityResolverComponent[0].restPath)) {
477
+ serverConfig.types.identityResolverComponent[0].restPath = "identity";
453
478
  }
454
- if (Is.arrayValue(coreEngineConfig.types.identityProfileComponent) &&
455
- !Is.stringValue(coreEngineConfig.types.identityProfileComponent[0].restPath)) {
456
- coreEngineConfig.types.identityProfileComponent[0].restPath = "identity/profile";
479
+ if (Is.arrayValue(serverConfig.types.identityProfileComponent) &&
480
+ !Is.stringValue(serverConfig.types.identityProfileComponent[0].restPath)) {
481
+ serverConfig.types.identityProfileComponent[0].restPath = "identity/profile";
457
482
  }
458
- if (Is.arrayValue(coreEngineConfig.types.nftComponent) &&
459
- !Is.stringValue(coreEngineConfig.types.nftComponent[0].restPath)) {
460
- coreEngineConfig.types.nftComponent[0].restPath = "nft";
483
+ if (Is.arrayValue(serverConfig.types.nftComponent) &&
484
+ !Is.stringValue(serverConfig.types.nftComponent[0].restPath)) {
485
+ serverConfig.types.nftComponent[0].restPath = "nft";
461
486
  }
462
- if (Is.arrayValue(coreEngineConfig.types.verifiableStorageComponent) &&
463
- !Is.stringValue(coreEngineConfig.types.verifiableStorageComponent[0].restPath)) {
464
- coreEngineConfig.types.verifiableStorageComponent[0].restPath = "verifiable";
487
+ if (Is.arrayValue(serverConfig.types.verifiableStorageComponent) &&
488
+ !Is.stringValue(serverConfig.types.verifiableStorageComponent[0].restPath)) {
489
+ serverConfig.types.verifiableStorageComponent[0].restPath = "verifiable";
465
490
  }
466
- if (Is.arrayValue(coreEngineConfig.types.immutableProofComponent) &&
467
- !Is.stringValue(coreEngineConfig.types.immutableProofComponent[0].restPath)) {
468
- coreEngineConfig.types.immutableProofComponent[0].restPath = "immutable-proof";
491
+ if (Is.arrayValue(serverConfig.types.immutableProofComponent) &&
492
+ !Is.stringValue(serverConfig.types.immutableProofComponent[0].restPath)) {
493
+ serverConfig.types.immutableProofComponent[0].restPath = "immutable-proof";
469
494
  }
470
- if (Is.arrayValue(coreEngineConfig.types.attestationComponent) &&
471
- !Is.stringValue(coreEngineConfig.types.attestationComponent[0].restPath)) {
472
- coreEngineConfig.types.attestationComponent[0].restPath = "attestation";
495
+ if (Is.arrayValue(serverConfig.types.attestationComponent) &&
496
+ !Is.stringValue(serverConfig.types.attestationComponent[0].restPath)) {
497
+ serverConfig.types.attestationComponent[0].restPath = "attestation";
473
498
  }
474
- if (Is.arrayValue(coreEngineConfig.types.auditableItemGraphComponent) &&
475
- !Is.stringValue(coreEngineConfig.types.auditableItemGraphComponent[0].restPath)) {
476
- coreEngineConfig.types.auditableItemGraphComponent[0].restPath = "aig";
499
+ if (Is.arrayValue(serverConfig.types.auditableItemGraphComponent) &&
500
+ !Is.stringValue(serverConfig.types.auditableItemGraphComponent[0].restPath)) {
501
+ serverConfig.types.auditableItemGraphComponent[0].restPath = "aig";
477
502
  }
478
- if (Is.arrayValue(coreEngineConfig.types.auditableItemStreamComponent) &&
479
- !Is.stringValue(coreEngineConfig.types.auditableItemStreamComponent[0].restPath)) {
480
- coreEngineConfig.types.auditableItemStreamComponent[0].restPath = "ais";
503
+ if (Is.arrayValue(serverConfig.types.auditableItemStreamComponent) &&
504
+ !Is.stringValue(serverConfig.types.auditableItemStreamComponent[0].restPath)) {
505
+ serverConfig.types.auditableItemStreamComponent[0].restPath = "ais";
481
506
  }
482
- if (Is.arrayValue(coreEngineConfig.types.dataProcessingComponent) &&
483
- !Is.stringValue(coreEngineConfig.types.dataProcessingComponent[0].restPath)) {
484
- coreEngineConfig.types.dataProcessingComponent[0].restPath = "data-processing";
507
+ if (Is.arrayValue(serverConfig.types.dataProcessingComponent) &&
508
+ !Is.stringValue(serverConfig.types.dataProcessingComponent[0].restPath)) {
509
+ serverConfig.types.dataProcessingComponent[0].restPath = "data-processing";
485
510
  }
486
- if (Is.arrayValue(coreEngineConfig.types.documentManagementComponent) &&
487
- !Is.stringValue(coreEngineConfig.types.documentManagementComponent[0].restPath)) {
488
- coreEngineConfig.types.documentManagementComponent[0].restPath = "document-management";
511
+ if (Is.arrayValue(serverConfig.types.documentManagementComponent) &&
512
+ !Is.stringValue(serverConfig.types.documentManagementComponent[0].restPath)) {
513
+ serverConfig.types.documentManagementComponent[0].restPath = "documents";
489
514
  }
490
515
  }
491
516
  /**
492
517
  * Adds the socket paths to the server config.
493
- * @param coreEngineConfig The core engine config.
494
518
  * @param serverConfig The server config.
495
519
  */
496
- function addSocketPaths(coreEngineConfig, serverConfig) {
497
- if (Is.arrayValue(coreEngineConfig.types.eventBusComponent) &&
498
- !Is.stringValue(coreEngineConfig.types.eventBusComponent[0].socketPath)) {
499
- coreEngineConfig.types.eventBusComponent[0].socketPath = "event-bus";
520
+ function addDefaultSocketPaths(serverConfig) {
521
+ if (Is.arrayValue(serverConfig.types.eventBusComponent) &&
522
+ !Is.stringValue(serverConfig.types.eventBusComponent[0].socketPath)) {
523
+ serverConfig.types.eventBusComponent[0].socketPath = "event-bus";
500
524
  }
501
525
  }
502
526
 
503
- export { EngineServer, buildEngineServerConfiguration };
527
+ export { EngineServer, addDefaultRestPaths, addDefaultSocketPaths, buildEngineServerConfiguration };
@@ -1,3 +1,4 @@
1
+ import type { IRestRoute, ISocketRoute } from "@twin.org/api-models";
1
2
  import type { IEngineCore, IEngineCoreTypeConfig, IEngineServer } from "@twin.org/engine-models";
2
3
  import { type IEngineServerConfig } from "@twin.org/engine-server-types";
3
4
  /**
@@ -32,6 +33,16 @@ export declare class EngineServer<T extends IEngineServerConfig = IEngineServerC
32
33
  * @param method The method to call on the module.
33
34
  */
34
35
  addSocketRouteGenerator(type: string, typeConfig: IEngineCoreTypeConfig[] | undefined, module: string, method: string): void;
36
+ /**
37
+ * Get the built REST routes.
38
+ * @returns The REST routes.
39
+ */
40
+ getRestRoutes(): IRestRoute[];
41
+ /**
42
+ * Get the built socket routes.
43
+ * @returns The socket routes.
44
+ */
45
+ getSocketRoutes(): ISocketRoute[];
35
46
  /**
36
47
  * Start the engine server.
37
48
  * @returns True if the start was successful.
@@ -11,3 +11,13 @@ import type { IEngineServerEnvironmentVariables } from "../models/IEngineServerE
11
11
  * @returns The the config for the core and the server.
12
12
  */
13
13
  export declare function buildEngineServerConfiguration(envVars: IEngineServerEnvironmentVariables, coreEngineConfig: IEngineCoreConfig, serverInfo: IServerInfo, openApiSpecPath?: string): IEngineServerConfig;
14
+ /**
15
+ * Adds the rest paths to the server config.
16
+ * @param serverConfig The server config.
17
+ */
18
+ export declare function addDefaultRestPaths(serverConfig: IEngineServerConfig): void;
19
+ /**
20
+ * Adds the socket paths to the server config.
21
+ * @param serverConfig The server config.
22
+ */
23
+ export declare function addDefaultSocketPaths(serverConfig: IEngineServerConfig): void;
package/docs/changelog.md CHANGED
@@ -1,5 +1,46 @@
1
1
  # @twin.org/engine-server - Changelog
2
2
 
3
+ ## [0.0.1-next.69](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.1-next.68...engine-server-v0.0.1-next.69) (2025-04-25)
4
+
5
+
6
+ ### Features
7
+
8
+ * expose default rest and socket path creation ([e6c6e26](https://github.com/twinfoundation/engine/commit/e6c6e266c8017212a74d4997e2e335347457a2bc))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * use abbreviated docs path ([9258a72](https://github.com/twinfoundation/engine/commit/9258a72adf266ddcc4f98002a07a7a162755f24b))
14
+
15
+
16
+ ### Dependencies
17
+
18
+ * The following workspace dependencies were updated
19
+ * dependencies
20
+ * @twin.org/engine-core bumped from 0.0.1-next.68 to 0.0.1-next.69
21
+ * @twin.org/engine-models bumped from 0.0.1-next.68 to 0.0.1-next.69
22
+ * @twin.org/engine-server-types bumped from 0.0.1-next.68 to 0.0.1-next.69
23
+ * devDependencies
24
+ * @twin.org/engine bumped from 0.0.1-next.68 to 0.0.1-next.69
25
+
26
+ ## [0.0.1-next.68](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.1-next.67...engine-server-v0.0.1-next.68) (2025-04-17)
27
+
28
+
29
+ ### Features
30
+
31
+ * use shared store mechanism ([#2](https://github.com/twinfoundation/engine/issues/2)) ([9eed8d7](https://github.com/twinfoundation/engine/commit/9eed8d7766388479b42f03e2542fe761f2156408))
32
+
33
+
34
+ ### Dependencies
35
+
36
+ * The following workspace dependencies were updated
37
+ * dependencies
38
+ * @twin.org/engine-core bumped from 0.0.1-next.67 to 0.0.1-next.68
39
+ * @twin.org/engine-models bumped from 0.0.1-next.67 to 0.0.1-next.68
40
+ * @twin.org/engine-server-types bumped from 0.0.1-next.67 to 0.0.1-next.68
41
+ * devDependencies
42
+ * @twin.org/engine bumped from 0.0.1-next.67 to 0.0.1-next.68
43
+
3
44
  ## [0.0.1-next.67](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.1-next.66...engine-server-v0.0.1-next.67) (2025-03-28)
4
45
 
5
46
 
@@ -4,7 +4,9 @@ Server for the engine.
4
4
 
5
5
  ## Type Parameters
6
6
 
7
- **T** *extends* `IEngineServerConfig` = `IEngineServerConfig`
7
+ ### T
8
+
9
+ `T` *extends* `IEngineServerConfig` = `IEngineServerConfig`
8
10
 
9
11
  ## Implements
10
12
 
@@ -12,9 +14,9 @@ Server for the engine.
12
14
 
13
15
  ## Constructors
14
16
 
15
- ### new EngineServer()
17
+ ### Constructor
16
18
 
17
- > **new EngineServer**\<`T`\>(`options`): [`EngineServer`](EngineServer.md)\<`T`\>
19
+ > **new EngineServer**\<`T`\>(`options`): `EngineServer`\<`T`\>
18
20
 
19
21
  Create a new instance of EngineServer.
20
22
 
@@ -32,7 +34,7 @@ The engine core to serve from.
32
34
 
33
35
  #### Returns
34
36
 
35
- [`EngineServer`](EngineServer.md)\<`T`\>
37
+ `EngineServer`\<`T`\>
36
38
 
37
39
  ## Properties
38
40
 
@@ -128,6 +130,34 @@ The method to call on the module.
128
130
 
129
131
  ***
130
132
 
133
+ ### getRestRoutes()
134
+
135
+ > **getRestRoutes**(): `IRestRoute`\<`any`, `any`\>[]
136
+
137
+ Get the built REST routes.
138
+
139
+ #### Returns
140
+
141
+ `IRestRoute`\<`any`, `any`\>[]
142
+
143
+ The REST routes.
144
+
145
+ ***
146
+
147
+ ### getSocketRoutes()
148
+
149
+ > **getSocketRoutes**(): `ISocketRoute`\<`any`, `any`\>[]
150
+
151
+ Get the built socket routes.
152
+
153
+ #### Returns
154
+
155
+ `ISocketRoute`\<`any`, `any`\>[]
156
+
157
+ The socket routes.
158
+
159
+ ***
160
+
131
161
  ### start()
132
162
 
133
163
  > **start**(): `Promise`\<`boolean`\>
@@ -0,0 +1,17 @@
1
+ # Function: addDefaultRestPaths()
2
+
3
+ > **addDefaultRestPaths**(`serverConfig`): `void`
4
+
5
+ Adds the rest paths to the server config.
6
+
7
+ ## Parameters
8
+
9
+ ### serverConfig
10
+
11
+ `IEngineServerConfig`
12
+
13
+ The server config.
14
+
15
+ ## Returns
16
+
17
+ `void`
@@ -0,0 +1,17 @@
1
+ # Function: addDefaultSocketPaths()
2
+
3
+ > **addDefaultSocketPaths**(`serverConfig`): `void`
4
+
5
+ Adds the socket paths to the server config.
6
+
7
+ ## Parameters
8
+
9
+ ### serverConfig
10
+
11
+ `IEngineServerConfig`
12
+
13
+ The server config.
14
+
15
+ ## Returns
16
+
17
+ `void`
@@ -1,6 +1,6 @@
1
1
  # Function: buildEngineServerConfiguration()
2
2
 
3
- > **buildEngineServerConfiguration**(`envVars`, `coreEngineConfig`, `serverInfo`, `openApiSpecPath`?): `IEngineServerConfig`
3
+ > **buildEngineServerConfiguration**(`envVars`, `coreEngineConfig`, `serverInfo`, `openApiSpecPath?`): `IEngineServerConfig`
4
4
 
5
5
  Handles the configuration of the server.
6
6
 
@@ -11,3 +11,5 @@
11
11
  ## Functions
12
12
 
13
13
  - [buildEngineServerConfiguration](functions/buildEngineServerConfiguration.md)
14
+ - [addDefaultRestPaths](functions/addDefaultRestPaths.md)
15
+ - [addDefaultSocketPaths](functions/addDefaultSocketPaths.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/engine-server",
3
- "version": "0.0.1-next.67",
3
+ "version": "0.0.1-next.69",
4
4
  "description": "Engine implementation for a server.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,9 +17,9 @@
17
17
  "@twin.org/api-models": "next",
18
18
  "@twin.org/api-server-fastify": "next",
19
19
  "@twin.org/core": "next",
20
- "@twin.org/engine-core": "0.0.1-next.67",
21
- "@twin.org/engine-models": "0.0.1-next.67",
22
- "@twin.org/engine-server-types": "0.0.1-next.67",
20
+ "@twin.org/engine-core": "0.0.1-next.69",
21
+ "@twin.org/engine-models": "0.0.1-next.69",
22
+ "@twin.org/engine-server-types": "0.0.1-next.69",
23
23
  "@twin.org/modules": "next",
24
24
  "@twin.org/nameof": "next"
25
25
  },