@3sixty/engine-server 0.20.0-next.1 → 0.20.0-next.3
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/es/data/serverRestRouteGenerators.json +7 -1
- package/dist/es/engineServer.js +45 -13
- package/dist/es/engineServer.js.map +1 -1
- package/dist/es/index.js.map +1 -1
- package/dist/es/utils/engineServerConfigHelper.js.map +1 -1
- package/docs/changelog.md +39 -0
- package/docs/examples.md +22 -0
- package/docs/reference/classes/EngineServer.md +8 -0
- package/package.json +7 -4
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
"type": "authenticationAuditComponent",
|
|
28
|
-
"module": "@3sixty/api-auth-
|
|
28
|
+
"module": "@3sixty/api-auth-service",
|
|
29
29
|
"method": "generateRestRoutesAuthenticationAudit",
|
|
30
30
|
"defaultPath": "/authentication/audit"
|
|
31
31
|
},
|
|
@@ -53,6 +53,12 @@
|
|
|
53
53
|
"method": "generateRestRoutesTracing",
|
|
54
54
|
"defaultPath": "/tracing"
|
|
55
55
|
},
|
|
56
|
+
{
|
|
57
|
+
"type": "authorizationComponent",
|
|
58
|
+
"module": "@3sixty/authorization-service",
|
|
59
|
+
"method": "generateRestRoutesAuthorization",
|
|
60
|
+
"defaultPath": "/authorization"
|
|
61
|
+
},
|
|
56
62
|
{
|
|
57
63
|
"type": "automationComponent",
|
|
58
64
|
"module": "@3sixty/automation-service",
|
package/dist/es/engineServer.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// Copyright 2026 3Sixty Trade Ltd.
|
|
2
3
|
// SPDX-License-Identifier: Apache-2.0.
|
|
3
4
|
import { MimeTypeProcessorFactory, RestRouteProcessorFactory, SocketRouteProcessorFactory } from "@3sixty/api-models";
|
|
4
5
|
import { FastifyWebServer } from "@3sixty/api-server-fastify";
|
|
6
|
+
import { HonoWebServer } from "@3sixty/api-server-hono";
|
|
7
|
+
import { NativeWebServer } from "@3sixty/api-server-native";
|
|
5
8
|
import { ContextIdStore } from "@3sixty/context";
|
|
6
9
|
import { Guards, Is, StringHelper } from "@3sixty/core";
|
|
7
|
-
import { RestRouteProcessorType, SocketRouteProcessorType } from "@3sixty/engine-server-types";
|
|
10
|
+
import { RestRouteProcessorType, SocketRouteProcessorType, WebServerType } from "@3sixty/engine-server-types";
|
|
8
11
|
import { ModuleHelper } from "@3sixty/modules";
|
|
9
12
|
import serverRestRouteGenerators from "./data/serverRestRouteGenerators.json" with { type: "json" };
|
|
10
13
|
import serverSocketRouteGenerators from "./data/serverSocketRouteGenerators.json" with { type: "json" };
|
|
@@ -218,18 +221,47 @@ export class EngineServer {
|
|
|
218
221
|
const socketRouteProcessors = SocketRouteProcessorFactory.names().map(n => SocketRouteProcessorFactory.get(n));
|
|
219
222
|
const mimeTypeProcessors = MimeTypeProcessorFactory.names().map(n => MimeTypeProcessorFactory.get(n));
|
|
220
223
|
const coreConfig = this._engineCore.getConfig();
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
224
|
+
const webServerType = coreConfig.webServerType ?? WebServerType.Fastify;
|
|
225
|
+
Guards.arrayOneOf(EngineServer.CLASS_NAME, "coreConfig.webServerType", webServerType, Object.values(WebServerType));
|
|
226
|
+
if (webServerType === WebServerType.Hono) {
|
|
227
|
+
this._webServer = new HonoWebServer({
|
|
228
|
+
loggingComponentType: coreConfig.silent
|
|
229
|
+
? undefined
|
|
230
|
+
: this._engineCore.getRegisteredSilencedType("logging", "HonoWebServer"),
|
|
231
|
+
mimeTypeProcessors,
|
|
232
|
+
config: {
|
|
233
|
+
includeErrorStack: coreConfig.debug,
|
|
234
|
+
web: coreConfig.web?.customWebConfig,
|
|
235
|
+
socket: coreConfig.web?.customSocketConfig
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
else if (webServerType === WebServerType.Native) {
|
|
240
|
+
this._webServer = new NativeWebServer({
|
|
241
|
+
loggingComponentType: coreConfig.silent
|
|
242
|
+
? undefined
|
|
243
|
+
: this._engineCore.getRegisteredSilencedType("logging", "NativeWebServer"),
|
|
244
|
+
mimeTypeProcessors,
|
|
245
|
+
config: {
|
|
246
|
+
includeErrorStack: coreConfig.debug,
|
|
247
|
+
web: coreConfig.web?.customWebConfig,
|
|
248
|
+
socket: coreConfig.web?.customSocketConfig
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
this._webServer = new FastifyWebServer({
|
|
254
|
+
loggingComponentType: coreConfig.silent
|
|
255
|
+
? undefined
|
|
256
|
+
: this._engineCore.getRegisteredSilencedType("logging", "FastifyWebServer"),
|
|
257
|
+
mimeTypeProcessors,
|
|
258
|
+
config: {
|
|
259
|
+
includeErrorStack: coreConfig.debug,
|
|
260
|
+
web: coreConfig.web?.customWebConfig,
|
|
261
|
+
socket: coreConfig.web?.customSocketConfig
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
}
|
|
233
265
|
await this._engineCore.addRegisteredComponent("webServer", this._webServer);
|
|
234
266
|
await this._webServer.build(restRouteProcessors, this._restRoutes, socketRouteProcessors, this._socketRoutes, coreConfig.web);
|
|
235
267
|
await this._webServer.start();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engineServer.js","sourceRoot":"","sources":["../../src/engineServer.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,wBAAwB,EACxB,yBAAyB,EACzB,2BAA2B,EAI3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAgC,MAAM,4BAA4B,CAAC;AAC5F,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAA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CAAC,qBAAqB,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;QAChF,CAAC;IACF,CAAC;IAED;;;OAGG;IACK,8BAA8B;QACrC,KAAK,MAAM,SAAS,IAAI,2BAA2B,EAAE,CAAC;YACrD,IAAI,CAAC,uBAAuB,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;QAClF,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tMimeTypeProcessorFactory,\n\tRestRouteProcessorFactory,\n\tSocketRouteProcessorFactory,\n\ttype IRestRoute,\n\ttype ISocketRoute,\n\ttype IWebServer\n} from \"@3sixty/api-models\";\nimport { FastifyWebServer, type IFastifyWebServerConfig } from \"@3sixty/api-server-fastify\";\nimport { ContextIdStore } from \"@3sixty/context\";\nimport { Guards, Is, StringHelper } from \"@3sixty/core\";\nimport type { IEngineCore, IEngineCoreTypeConfig, IEngineServer } from \"@3sixty/engine-models\";\nimport {\n\tRestRouteProcessorType,\n\tSocketRouteProcessorType,\n\ttype IEngineServerConfig\n} from \"@3sixty/engine-server-types\";\nimport { ModuleHelper } from \"@3sixty/modules\";\nimport { nameof } from \"@3sixty/nameof\";\nimport serverRestRouteGenerators from \"./data/serverRestRouteGenerators.json\" with { type: \"json\" };\nimport serverSocketRouteGenerators from \"./data/serverSocketRouteGenerators.json\" with { type: \"json\" };\nimport serverTypeInitialisers from \"./data/serverTypeInitialisers.json\" with { type: \"json\" };\n\n/**\n * Server for the engine.\n */\nexport class EngineServer<\n\tT extends IEngineServerConfig = IEngineServerConfig\n> implements IEngineServer {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<EngineServer>();\n\n\t/**\n\t * The engine.\n\t * @internal\n\t */\n\tprivate readonly _engineCore: IEngineCore<T>;\n\n\t/**\n\t * The REST route generators.\n\t * @internal\n\t */\n\tprivate readonly _restRouteGenerators: {\n\t\ttype: string;\n\t\tmodule: string;\n\t\tmethod: string;\n\t}[];\n\n\t/**\n\t * The socket route generators.\n\t * @internal\n\t */\n\tprivate readonly _socketRouteGenerators: {\n\t\ttype: string;\n\t\tmodule: string;\n\t\tmethod: string;\n\t}[];\n\n\t/**\n\t * The web server.\n\t * @internal\n\t */\n\tprivate _webServer?: IWebServer<unknown>;\n\n\t/**\n\t * The REST routes for the application.\n\t * @internal\n\t */\n\tprivate _restRoutes: IRestRoute[];\n\n\t/**\n\t * The Socket routes for the application.\n\t * @internal\n\t */\n\tprivate _socketRoutes: ISocketRoute[];\n\n\t/**\n\t * Create a new instance of EngineServer.\n\t * @param options The options for the engine.\n\t * @param options.engineCore The engine core to serve from.\n\t */\n\tconstructor(options: { engineCore: IEngineCore<T> }) {\n\t\tGuards.object(EngineServer.CLASS_NAME, nameof(options), options);\n\t\tGuards.object(EngineServer.CLASS_NAME, nameof(options.engineCore), options.engineCore);\n\n\t\tthis._engineCore = options.engineCore;\n\t\tthis._restRouteGenerators = [];\n\t\tthis._socketRouteGenerators = [];\n\t\tthis._restRoutes = [];\n\t\tthis._socketRoutes = [];\n\n\t\tconst coreConfig = this._engineCore.getConfig();\n\n\t\tif (!Is.arrayValue(coreConfig.types.restRouteProcessor)) {\n\t\t\tcoreConfig.types.restRouteProcessor = [];\n\n\t\t\tif (!coreConfig.silent) {\n\t\t\t\tcoreConfig.types.restRouteProcessor.push({\n\t\t\t\t\ttype: RestRouteProcessorType.Logging,\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\tincludeBody: coreConfig.debug\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\tcoreConfig.types.restRouteProcessor.push({\n\t\t\t\ttype: RestRouteProcessorType.RestRoute,\n\t\t\t\toptions: {\n\t\t\t\t\tconfig: {\n\t\t\t\t\t\tincludeErrorStack: coreConfig.debug\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tif (!Is.arrayValue(coreConfig.types.socketRouteProcessor)) {\n\t\t\tcoreConfig.types.socketRouteProcessor = [];\n\n\t\t\tif (!coreConfig.silent) {\n\t\t\t\tcoreConfig.types.socketRouteProcessor.push({\n\t\t\t\t\ttype: SocketRouteProcessorType.Logging,\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\tincludeBody: coreConfig.debug\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\tcoreConfig.types.socketRouteProcessor.push({\n\t\t\t\ttype: SocketRouteProcessorType.SocketRoute,\n\t\t\t\toptions: {\n\t\t\t\t\tconfig: {\n\t\t\t\t\t\tincludeErrorStack: coreConfig.debug\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tthis.addServerTypeInitialisers();\n\t\tthis.addServerRestRouteGenerators();\n\t\tthis.addServerSocketRouteGenerators();\n\t}\n\n\t/**\n\t * Add a REST route generator.\n\t * @param type The type to add the generator for.\n\t * @param module The module containing the generator.\n\t * @param method The method to call on the module.\n\t */\n\tpublic addRestRouteGenerator(type: string, module: string, method: string): void {\n\t\tGuards.stringValue(EngineServer.CLASS_NAME, nameof(type), type);\n\t\tGuards.stringValue(EngineServer.CLASS_NAME, nameof(module), module);\n\t\tGuards.stringValue(EngineServer.CLASS_NAME, nameof(method), method);\n\n\t\tconst currentIndex = this._restRouteGenerators.findIndex(r => r.type === type);\n\t\tif (currentIndex >= 0) {\n\t\t\tthis._restRouteGenerators[currentIndex].module = module;\n\t\t\tthis._restRouteGenerators[currentIndex].method = method;\n\t\t} else {\n\t\t\tthis._restRouteGenerators.push({\n\t\t\t\ttype,\n\t\t\t\tmodule,\n\t\t\t\tmethod\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Add a socket route generator.\n\t * @param type The type to add the generator for.\n\t * @param module The module containing the generator.\n\t * @param method The method to call on the module.\n\t */\n\tpublic addSocketRouteGenerator(type: string, module: string, method: string): void {\n\t\tGuards.stringValue(EngineServer.CLASS_NAME, nameof(type), type);\n\t\tGuards.stringValue(EngineServer.CLASS_NAME, nameof(module), module);\n\t\tGuards.stringValue(EngineServer.CLASS_NAME, nameof(method), method);\n\n\t\tconst currentIndex = this._socketRouteGenerators.findIndex(s => s.type === type);\n\t\tif (currentIndex >= 0) {\n\t\t\tthis._socketRouteGenerators[currentIndex].module = module;\n\t\t\tthis._socketRouteGenerators[currentIndex].method = method;\n\t\t} else {\n\t\t\tthis._socketRouteGenerators.push({\n\t\t\t\ttype,\n\t\t\t\tmodule,\n\t\t\t\tmethod\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Get the built REST routes.\n\t * @returns The REST routes.\n\t */\n\tpublic getRestRoutes(): IRestRoute[] {\n\t\treturn this._restRoutes;\n\t}\n\n\t/**\n\t * Get the built socket routes.\n\t * @returns The socket routes.\n\t */\n\tpublic getSocketRoutes(): ISocketRoute[] {\n\t\treturn this._socketRoutes;\n\t}\n\n\t/**\n\t * Start the engine server.\n\t * @returns A promise that resolves when the server has started and is ready to accept requests.\n\t */\n\tpublic async start(): Promise<void> {\n\t\tawait this._engineCore.start();\n\n\t\ttry {\n\t\t\tawait ContextIdStore.run(this._engineCore.getContextIds() ?? {}, async () => {\n\t\t\t\tawait this.startWebServer();\n\t\t\t});\n\t\t} catch (err) {\n\t\t\t// The engine components are already running, so they must be stopped when the\n\t\t\t// web server fails to start, the web server itself never started so is discarded.\n\t\t\tthis._webServer = undefined;\n\t\t\tawait this._engineCore.stop();\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\t/**\n\t * Stop the engine server.\n\t * @returns A promise that resolves when the server has stopped and all connections are closed.\n\t */\n\tpublic async stop(): Promise<void> {\n\t\ttry {\n\t\t\tawait ContextIdStore.run(this._engineCore.getContextIds() ?? {}, async () => {\n\t\t\t\tif (this._webServer) {\n\t\t\t\t\tconst webServer = this._webServer;\n\t\t\t\t\tthis._webServer = undefined;\n\t\t\t\t\tawait webServer.stop();\n\t\t\t\t}\n\t\t\t});\n\t\t} finally {\n\t\t\t// The engine is always stopped so its components are shut down and state is saved,\n\t\t\t// even if the web server fails to stop.\n\t\t\tawait this._engineCore.stop();\n\t\t}\n\t}\n\n\t/**\n\t * Starts the web server.\n\t * @returns A promise that resolves when the web server is built and listening.\n\t * @internal\n\t */\n\tprivate async startWebServer(): Promise<void> {\n\t\tthis._restRoutes = await this.buildRestRoutes();\n\t\tthis._socketRoutes = await this.buildSocketRoutes();\n\t\tconst restRouteProcessors = RestRouteProcessorFactory.names().map(n =>\n\t\t\tRestRouteProcessorFactory.get(n)\n\t\t);\n\t\tconst socketRouteProcessors = SocketRouteProcessorFactory.names().map(n =>\n\t\t\tSocketRouteProcessorFactory.get(n)\n\t\t);\n\t\tconst mimeTypeProcessors = MimeTypeProcessorFactory.names().map(n =>\n\t\t\tMimeTypeProcessorFactory.get(n)\n\t\t);\n\n\t\tconst coreConfig = this._engineCore.getConfig();\n\t\tconst loggingComponentType = coreConfig.silent\n\t\t\t? undefined\n\t\t\t: this._engineCore.getRegisteredSilencedType(\"logging\", nameof(FastifyWebServer));\n\n\t\tthis._webServer = new FastifyWebServer({\n\t\t\tloggingComponentType,\n\t\t\tmimeTypeProcessors,\n\t\t\tconfig: {\n\t\t\t\tincludeErrorStack: coreConfig.debug,\n\t\t\t\tweb: coreConfig.web?.customWebConfig as IFastifyWebServerConfig[\"web\"],\n\t\t\t\tsocket: coreConfig.web?.customSocketConfig as IFastifyWebServerConfig[\"socket\"]\n\t\t\t}\n\t\t});\n\n\t\tawait this._engineCore.addRegisteredComponent(\"webServer\", this._webServer);\n\n\t\tawait this._webServer.build(\n\t\t\trestRouteProcessors,\n\t\t\tthis._restRoutes,\n\t\t\tsocketRouteProcessors,\n\t\t\tthis._socketRoutes,\n\t\t\tcoreConfig.web\n\t\t);\n\t\tawait this._webServer.start();\n\t}\n\n\t/**\n\t * The REST routes for the application.\n\t * @returns The REST routes for the application.\n\t * @internal\n\t */\n\tprivate async buildRestRoutes(): Promise<IRestRoute[]> {\n\t\tconst routes: IRestRoute[] = [];\n\n\t\tfor (const { type, module, method } of this._restRouteGenerators) {\n\t\t\tawait this.initialiseRestTypeRoute(routes, type, module, method);\n\t\t}\n\n\t\treturn routes;\n\t}\n\n\t/**\n\t * The socket routes for the application.\n\t * @returns The socket routes for the application.\n\t * @internal\n\t */\n\tprivate async buildSocketRoutes(): Promise<ISocketRoute[]> {\n\t\tconst routes: ISocketRoute[] = [];\n\n\t\tfor (const { type, module, method } of this._socketRouteGenerators) {\n\t\t\tawait this.initialiseSocketTypeRoute(routes, type, module, method);\n\t\t}\n\n\t\treturn routes;\n\t}\n\n\t/**\n\t * Initialise the rest routes from connector.\n\t * @param routes The routes to add to.\n\t * @param typeKey The key for the default types.\n\t * @param module The module containing the route generator.\n\t * @param method The method to generate the routes.\n\t * @returns A promise that resolves when all REST routes for the type have been added.\n\t * @internal\n\t */\n\tprivate async initialiseRestTypeRoute(\n\t\troutes: IRestRoute[],\n\t\ttypeKey: string,\n\t\tmodule: string,\n\t\tmethod: string\n\t): Promise<void> {\n\t\tconst typeConfig: IEngineCoreTypeConfig[] | undefined = this._engineCore.getTypeConfig(typeKey);\n\n\t\tif (Is.arrayValue(typeConfig)) {\n\t\t\tconst generateRoutes = await ModuleHelper.getModuleEntry<\n\t\t\t\t(baseRouteName: string, componentName: string, options?: unknown) => IRestRoute[]\n\t\t\t>(module, method);\n\n\t\t\tfor (let i = 0; i < typeConfig.length; i++) {\n\t\t\t\tconst restPath = typeConfig[i].restPath;\n\t\t\t\tconst restOptions = typeConfig[i].restOptions;\n\n\t\t\t\tif (Is.string(restPath)) {\n\t\t\t\t\tconst serviceType =\n\t\t\t\t\t\ttypeConfig[i].overrideInstanceType ??\n\t\t\t\t\t\tthis._engineCore.getRegisteredInstanceType(typeKey);\n\t\t\t\t\tif (Is.stringValue(serviceType)) {\n\t\t\t\t\t\tconst generatedRoutes = generateRoutes(restPath, serviceType, restOptions);\n\t\t\t\t\t\tfor (const route of generatedRoutes) {\n\t\t\t\t\t\t\t// Don't strip trailing slashes from the root path.\n\t\t\t\t\t\t\tif (Is.stringValue(route.path) && route.path.length > 1) {\n\t\t\t\t\t\t\t\troute.path = StringHelper.trimTrailingSlashes(route.path);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\troutes.push(...generatedRoutes);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Initialise the socket routes from connector.\n\t * @param routes The routes to add to.\n\t * @param typeKey The key for the default types.\n\t * @param module The module containing the generator.\n\t * @param method The method to call on the module.\n\t * @returns A promise that resolves when all socket routes for the type have been added.\n\t * @internal\n\t */\n\tprivate async initialiseSocketTypeRoute(\n\t\troutes: ISocketRoute[],\n\t\ttypeKey: string,\n\t\tmodule: string,\n\t\tmethod: string\n\t): Promise<void> {\n\t\tconst typeConfig: IEngineCoreTypeConfig[] | undefined = this._engineCore.getTypeConfig(typeKey);\n\n\t\tif (Is.arrayValue(typeConfig)) {\n\t\t\tconst generateRoutes = await ModuleHelper.getModuleEntry<\n\t\t\t\t(baseRouteName: string, componentName: string, options?: unknown) => ISocketRoute[]\n\t\t\t>(module, method);\n\n\t\t\tfor (let i = 0; i < typeConfig.length; i++) {\n\t\t\t\tconst socketPath = typeConfig[i].socketPath;\n\t\t\t\tconst socketOptions = typeConfig[i].socketOptions;\n\t\t\t\tif (Is.string(socketPath)) {\n\t\t\t\t\tconst serviceType =\n\t\t\t\t\t\ttypeConfig[i].overrideInstanceType ??\n\t\t\t\t\t\tthis._engineCore.getRegisteredInstanceType(typeKey);\n\t\t\t\t\tif (Is.stringValue(serviceType)) {\n\t\t\t\t\t\troutes.push(...generateRoutes(socketPath, serviceType, socketOptions));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Add the server type initializers.\n\t * @internal\n\t */\n\tprivate addServerTypeInitialisers(): void {\n\t\tfor (const initializer of serverTypeInitialisers) {\n\t\t\tthis._engineCore.addTypeInitialiser(initializer.type, initializer.module, initializer.method);\n\t\t}\n\t}\n\n\t/**\n\t * Add the server REST route generators.\n\t * @internal\n\t */\n\tprivate addServerRestRouteGenerators(): void {\n\t\tfor (const generator of serverRestRouteGenerators) {\n\t\t\tthis.addRestRouteGenerator(generator.type, generator.module, generator.method);\n\t\t}\n\t}\n\n\t/**\n\t * Add the server socket route generators.\n\t * @internal\n\t */\n\tprivate addServerSocketRouteGenerators(): void {\n\t\tfor (const generator of serverSocketRouteGenerators) {\n\t\t\tthis.addSocketRouteGenerator(generator.type, generator.module, generator.method);\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"engineServer.js","sources":["../../src/engineServer.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,mCAAmC;AACnC,uCAAuC;AACvC,OAAO,EACN,wBAAwB,EACxB,yBAAyB,EACzB,2BAA2B,EAI3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAgC,MAAM,4BAA4B,CAAC;AAC5F,OAAO,EAAE,aAAa,EAA6B,MAAM,yBAAyB,CAAC;AACnF,OAAO,EAAE,eAAe,EAA+B,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,EACN,sBAAsB,EACtB,wBAAwB,EACxB,aAAa,EAEb,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,yBAAyB,MAAM,uCAAuC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACpG,OAAO,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AE,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;QAClF,CAAC;IACF,CAAC;CACD","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// Copyright 2026 3Sixty Trade Ltd.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tMimeTypeProcessorFactory,\n\tRestRouteProcessorFactory,\n\tSocketRouteProcessorFactory,\n\ttype IRestRoute,\n\ttype ISocketRoute,\n\ttype IWebServer\n} from \"@3sixty/api-models\";\nimport { FastifyWebServer, type IFastifyWebServerConfig } from \"@3sixty/api-server-fastify\";\nimport { HonoWebServer, type IHonoWebServerConfig } from \"@3sixty/api-server-hono\";\nimport { NativeWebServer, type INativeWebServerConfig } from \"@3sixty/api-server-native\";\nimport { ContextIdStore } from \"@3sixty/context\";\nimport { Guards, Is, StringHelper } from \"@3sixty/core\";\nimport type { IEngineCore, IEngineCoreTypeConfig, IEngineServer } from \"@3sixty/engine-models\";\nimport {\n\tRestRouteProcessorType,\n\tSocketRouteProcessorType,\n\tWebServerType,\n\ttype IEngineServerConfig\n} from \"@3sixty/engine-server-types\";\nimport { ModuleHelper } from \"@3sixty/modules\";\n\nimport serverRestRouteGenerators from \"./data/serverRestRouteGenerators.json\" with { type: \"json\" };\nimport serverSocketRouteGenerators from \"./data/serverSocketRouteGenerators.json\" with { type: \"json\" };\nimport serverTypeInitialisers from \"./data/serverTypeInitialisers.json\" with { type: \"json\" };\n\n/**\n * Server for the engine.\n */\nexport class EngineServer<\n\tT extends IEngineServerConfig = IEngineServerConfig\n> implements IEngineServer {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = \"EngineServer\";\n\n\t/**\n\t * The engine.\n\t * @internal\n\t */\n\tprivate readonly _engineCore: IEngineCore<T>;\n\n\t/**\n\t * The REST route generators.\n\t * @internal\n\t */\n\tprivate readonly _restRouteGenerators: {\n\t\ttype: string;\n\t\tmodule: string;\n\t\tmethod: string;\n\t}[];\n\n\t/**\n\t * The socket route generators.\n\t * @internal\n\t */\n\tprivate readonly _socketRouteGenerators: {\n\t\ttype: string;\n\t\tmodule: string;\n\t\tmethod: string;\n\t}[];\n\n\t/**\n\t * The web server.\n\t * @internal\n\t */\n\tprivate _webServer?: IWebServer<unknown>;\n\n\t/**\n\t * The REST routes for the application.\n\t * @internal\n\t */\n\tprivate _restRoutes: IRestRoute[];\n\n\t/**\n\t * The Socket routes for the application.\n\t * @internal\n\t */\n\tprivate _socketRoutes: ISocketRoute[];\n\n\t/**\n\t * Create a new instance of EngineServer.\n\t * @param options The options for the engine.\n\t * @param options.engineCore The engine core to serve from.\n\t */\n\tconstructor(options: { engineCore: IEngineCore<T> }) {\n\t\tGuards.object(EngineServer.CLASS_NAME, \"options\", options);\n\t\tGuards.object(EngineServer.CLASS_NAME, \"options.engineCore\", options.engineCore);\n\n\t\tthis._engineCore = options.engineCore;\n\t\tthis._restRouteGenerators = [];\n\t\tthis._socketRouteGenerators = [];\n\t\tthis._restRoutes = [];\n\t\tthis._socketRoutes = [];\n\n\t\tconst coreConfig = this._engineCore.getConfig();\n\n\t\tif (!Is.arrayValue(coreConfig.types.restRouteProcessor)) {\n\t\t\tcoreConfig.types.restRouteProcessor = [];\n\n\t\t\tif (!coreConfig.silent) {\n\t\t\t\tcoreConfig.types.restRouteProcessor.push({\n\t\t\t\t\ttype: RestRouteProcessorType.Logging,\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\tincludeBody: coreConfig.debug\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\tcoreConfig.types.restRouteProcessor.push({\n\t\t\t\ttype: RestRouteProcessorType.RestRoute,\n\t\t\t\toptions: {\n\t\t\t\t\tconfig: {\n\t\t\t\t\t\tincludeErrorStack: coreConfig.debug\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tif (!Is.arrayValue(coreConfig.types.socketRouteProcessor)) {\n\t\t\tcoreConfig.types.socketRouteProcessor = [];\n\n\t\t\tif (!coreConfig.silent) {\n\t\t\t\tcoreConfig.types.socketRouteProcessor.push({\n\t\t\t\t\ttype: SocketRouteProcessorType.Logging,\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\tincludeBody: coreConfig.debug\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\tcoreConfig.types.socketRouteProcessor.push({\n\t\t\t\ttype: SocketRouteProcessorType.SocketRoute,\n\t\t\t\toptions: {\n\t\t\t\t\tconfig: {\n\t\t\t\t\t\tincludeErrorStack: coreConfig.debug\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tthis.addServerTypeInitialisers();\n\t\tthis.addServerRestRouteGenerators();\n\t\tthis.addServerSocketRouteGenerators();\n\t}\n\n\t/**\n\t * Add a REST route generator.\n\t * @param type The type to add the generator for.\n\t * @param module The module containing the generator.\n\t * @param method The method to call on the module.\n\t */\n\tpublic addRestRouteGenerator(type: string, module: string, method: string): void {\n\t\tGuards.stringValue(EngineServer.CLASS_NAME, \"type\", type);\n\t\tGuards.stringValue(EngineServer.CLASS_NAME, \"module\", module);\n\t\tGuards.stringValue(EngineServer.CLASS_NAME, \"method\", method);\n\n\t\tconst currentIndex = this._restRouteGenerators.findIndex(r => r.type === type);\n\t\tif (currentIndex >= 0) {\n\t\t\tthis._restRouteGenerators[currentIndex].module = module;\n\t\t\tthis._restRouteGenerators[currentIndex].method = method;\n\t\t} else {\n\t\t\tthis._restRouteGenerators.push({\n\t\t\t\ttype,\n\t\t\t\tmodule,\n\t\t\t\tmethod\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Add a socket route generator.\n\t * @param type The type to add the generator for.\n\t * @param module The module containing the generator.\n\t * @param method The method to call on the module.\n\t */\n\tpublic addSocketRouteGenerator(type: string, module: string, method: string): void {\n\t\tGuards.stringValue(EngineServer.CLASS_NAME, \"type\", type);\n\t\tGuards.stringValue(EngineServer.CLASS_NAME, \"module\", module);\n\t\tGuards.stringValue(EngineServer.CLASS_NAME, \"method\", method);\n\n\t\tconst currentIndex = this._socketRouteGenerators.findIndex(s => s.type === type);\n\t\tif (currentIndex >= 0) {\n\t\t\tthis._socketRouteGenerators[currentIndex].module = module;\n\t\t\tthis._socketRouteGenerators[currentIndex].method = method;\n\t\t} else {\n\t\t\tthis._socketRouteGenerators.push({\n\t\t\t\ttype,\n\t\t\t\tmodule,\n\t\t\t\tmethod\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Get the built REST routes.\n\t * @returns The REST routes.\n\t */\n\tpublic getRestRoutes(): IRestRoute[] {\n\t\treturn this._restRoutes;\n\t}\n\n\t/**\n\t * Get the built socket routes.\n\t * @returns The socket routes.\n\t */\n\tpublic getSocketRoutes(): ISocketRoute[] {\n\t\treturn this._socketRoutes;\n\t}\n\n\t/**\n\t * Start the engine server.\n\t * @returns A promise that resolves when the server has started and is ready to accept requests.\n\t */\n\tpublic async start(): Promise<void> {\n\t\tawait this._engineCore.start();\n\n\t\ttry {\n\t\t\tawait ContextIdStore.run(this._engineCore.getContextIds() ?? {}, async () => {\n\t\t\t\tawait this.startWebServer();\n\t\t\t});\n\t\t} catch (err) {\n\t\t\t// The engine components are already running, so they must be stopped when the\n\t\t\t// web server fails to start, the web server itself never started so is discarded.\n\t\t\tthis._webServer = undefined;\n\t\t\tawait this._engineCore.stop();\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\t/**\n\t * Stop the engine server.\n\t * @returns A promise that resolves when the server has stopped and all connections are closed.\n\t */\n\tpublic async stop(): Promise<void> {\n\t\ttry {\n\t\t\tawait ContextIdStore.run(this._engineCore.getContextIds() ?? {}, async () => {\n\t\t\t\tif (this._webServer) {\n\t\t\t\t\tconst webServer = this._webServer;\n\t\t\t\t\tthis._webServer = undefined;\n\t\t\t\t\tawait webServer.stop();\n\t\t\t\t}\n\t\t\t});\n\t\t} finally {\n\t\t\t// The engine is always stopped so its components are shut down and state is saved,\n\t\t\t// even if the web server fails to stop.\n\t\t\tawait this._engineCore.stop();\n\t\t}\n\t}\n\n\t/**\n\t * Starts the web server.\n\t * @returns A promise that resolves when the web server is built and listening.\n\t * @internal\n\t */\n\tprivate async startWebServer(): Promise<void> {\n\t\tthis._restRoutes = await this.buildRestRoutes();\n\t\tthis._socketRoutes = await this.buildSocketRoutes();\n\t\tconst restRouteProcessors = RestRouteProcessorFactory.names().map(n =>\n\t\t\tRestRouteProcessorFactory.get(n)\n\t\t);\n\t\tconst socketRouteProcessors = SocketRouteProcessorFactory.names().map(n =>\n\t\t\tSocketRouteProcessorFactory.get(n)\n\t\t);\n\t\tconst mimeTypeProcessors = MimeTypeProcessorFactory.names().map(n =>\n\t\t\tMimeTypeProcessorFactory.get(n)\n\t\t);\n\n\t\tconst coreConfig = this._engineCore.getConfig();\n\t\tconst webServerType = coreConfig.webServerType ?? WebServerType.Fastify;\n\t\tGuards.arrayOneOf<WebServerType>(\n\t\t\tEngineServer.CLASS_NAME,\n\t\t\t\"coreConfig.webServerType\",\n\t\t\twebServerType,\n\t\t\tObject.values(WebServerType)\n\t\t);\n\n\t\tif (webServerType === WebServerType.Hono) {\n\t\t\tthis._webServer = new HonoWebServer({\n\t\t\t\tloggingComponentType: coreConfig.silent\n\t\t\t\t\t? undefined\n\t\t\t\t\t: this._engineCore.getRegisteredSilencedType(\"logging\", \"HonoWebServer\"),\n\t\t\t\tmimeTypeProcessors,\n\t\t\t\tconfig: {\n\t\t\t\t\tincludeErrorStack: coreConfig.debug,\n\t\t\t\t\tweb: coreConfig.web?.customWebConfig as IHonoWebServerConfig[\"web\"],\n\t\t\t\t\tsocket: coreConfig.web?.customSocketConfig as IHonoWebServerConfig[\"socket\"]\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (webServerType === WebServerType.Native) {\n\t\t\tthis._webServer = new NativeWebServer({\n\t\t\t\tloggingComponentType: coreConfig.silent\n\t\t\t\t\t? undefined\n\t\t\t\t\t: this._engineCore.getRegisteredSilencedType(\"logging\", \"NativeWebServer\"),\n\t\t\t\tmimeTypeProcessors,\n\t\t\t\tconfig: {\n\t\t\t\t\tincludeErrorStack: coreConfig.debug,\n\t\t\t\t\tweb: coreConfig.web?.customWebConfig as INativeWebServerConfig[\"web\"],\n\t\t\t\t\tsocket: coreConfig.web?.customSocketConfig as INativeWebServerConfig[\"socket\"]\n\t\t\t\t}\n\t\t\t});\n\t\t} else {\n\t\t\tthis._webServer = new FastifyWebServer({\n\t\t\t\tloggingComponentType: coreConfig.silent\n\t\t\t\t\t? undefined\n\t\t\t\t\t: this._engineCore.getRegisteredSilencedType(\"logging\", \"FastifyWebServer\"),\n\t\t\t\tmimeTypeProcessors,\n\t\t\t\tconfig: {\n\t\t\t\t\tincludeErrorStack: coreConfig.debug,\n\t\t\t\t\tweb: coreConfig.web?.customWebConfig as IFastifyWebServerConfig[\"web\"],\n\t\t\t\t\tsocket: coreConfig.web?.customSocketConfig as IFastifyWebServerConfig[\"socket\"]\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tawait this._engineCore.addRegisteredComponent(\"webServer\", this._webServer);\n\n\t\tawait this._webServer.build(\n\t\t\trestRouteProcessors,\n\t\t\tthis._restRoutes,\n\t\t\tsocketRouteProcessors,\n\t\t\tthis._socketRoutes,\n\t\t\tcoreConfig.web\n\t\t);\n\t\tawait this._webServer.start();\n\t}\n\n\t/**\n\t * The REST routes for the application.\n\t * @returns The REST routes for the application.\n\t * @internal\n\t */\n\tprivate async buildRestRoutes(): Promise<IRestRoute[]> {\n\t\tconst routes: IRestRoute[] = [];\n\n\t\tfor (const { type, module, method } of this._restRouteGenerators) {\n\t\t\tawait this.initialiseRestTypeRoute(routes, type, module, method);\n\t\t}\n\n\t\treturn routes;\n\t}\n\n\t/**\n\t * The socket routes for the application.\n\t * @returns The socket routes for the application.\n\t * @internal\n\t */\n\tprivate async buildSocketRoutes(): Promise<ISocketRoute[]> {\n\t\tconst routes: ISocketRoute[] = [];\n\n\t\tfor (const { type, module, method } of this._socketRouteGenerators) {\n\t\t\tawait this.initialiseSocketTypeRoute(routes, type, module, method);\n\t\t}\n\n\t\treturn routes;\n\t}\n\n\t/**\n\t * Initialise the rest routes from connector.\n\t * @param routes The routes to add to.\n\t * @param typeKey The key for the default types.\n\t * @param module The module containing the route generator.\n\t * @param method The method to generate the routes.\n\t * @returns A promise that resolves when all REST routes for the type have been added.\n\t * @internal\n\t */\n\tprivate async initialiseRestTypeRoute(\n\t\troutes: IRestRoute[],\n\t\ttypeKey: string,\n\t\tmodule: string,\n\t\tmethod: string\n\t): Promise<void> {\n\t\tconst typeConfig: IEngineCoreTypeConfig[] | undefined = this._engineCore.getTypeConfig(typeKey);\n\n\t\tif (Is.arrayValue(typeConfig)) {\n\t\t\tconst generateRoutes = await ModuleHelper.getModuleEntry<\n\t\t\t\t(baseRouteName: string, componentName: string, options?: unknown) => IRestRoute[]\n\t\t\t>(module, method);\n\n\t\t\tfor (let i = 0; i < typeConfig.length; i++) {\n\t\t\t\tconst restPath = typeConfig[i].restPath;\n\t\t\t\tconst restOptions = typeConfig[i].restOptions;\n\n\t\t\t\tif (Is.string(restPath)) {\n\t\t\t\t\tconst serviceType =\n\t\t\t\t\t\ttypeConfig[i].overrideInstanceType ??\n\t\t\t\t\t\tthis._engineCore.getRegisteredInstanceType(typeKey);\n\t\t\t\t\tif (Is.stringValue(serviceType)) {\n\t\t\t\t\t\tconst generatedRoutes = generateRoutes(restPath, serviceType, restOptions);\n\t\t\t\t\t\tfor (const route of generatedRoutes) {\n\t\t\t\t\t\t\t// Don't strip trailing slashes from the root path.\n\t\t\t\t\t\t\tif (Is.stringValue(route.path) && route.path.length > 1) {\n\t\t\t\t\t\t\t\troute.path = StringHelper.trimTrailingSlashes(route.path);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\troutes.push(...generatedRoutes);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Initialise the socket routes from connector.\n\t * @param routes The routes to add to.\n\t * @param typeKey The key for the default types.\n\t * @param module The module containing the generator.\n\t * @param method The method to call on the module.\n\t * @returns A promise that resolves when all socket routes for the type have been added.\n\t * @internal\n\t */\n\tprivate async initialiseSocketTypeRoute(\n\t\troutes: ISocketRoute[],\n\t\ttypeKey: string,\n\t\tmodule: string,\n\t\tmethod: string\n\t): Promise<void> {\n\t\tconst typeConfig: IEngineCoreTypeConfig[] | undefined = this._engineCore.getTypeConfig(typeKey);\n\n\t\tif (Is.arrayValue(typeConfig)) {\n\t\t\tconst generateRoutes = await ModuleHelper.getModuleEntry<\n\t\t\t\t(baseRouteName: string, componentName: string, options?: unknown) => ISocketRoute[]\n\t\t\t>(module, method);\n\n\t\t\tfor (let i = 0; i < typeConfig.length; i++) {\n\t\t\t\tconst socketPath = typeConfig[i].socketPath;\n\t\t\t\tconst socketOptions = typeConfig[i].socketOptions;\n\t\t\t\tif (Is.string(socketPath)) {\n\t\t\t\t\tconst serviceType =\n\t\t\t\t\t\ttypeConfig[i].overrideInstanceType ??\n\t\t\t\t\t\tthis._engineCore.getRegisteredInstanceType(typeKey);\n\t\t\t\t\tif (Is.stringValue(serviceType)) {\n\t\t\t\t\t\troutes.push(...generateRoutes(socketPath, serviceType, socketOptions));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Add the server type initializers.\n\t * @internal\n\t */\n\tprivate addServerTypeInitialisers(): void {\n\t\tfor (const initializer of serverTypeInitialisers) {\n\t\t\tthis._engineCore.addTypeInitialiser(initializer.type, initializer.module, initializer.method);\n\t\t}\n\t}\n\n\t/**\n\t * Add the server REST route generators.\n\t * @internal\n\t */\n\tprivate addServerRestRouteGenerators(): void {\n\t\tfor (const generator of serverRestRouteGenerators) {\n\t\t\tthis.addRestRouteGenerator(generator.type, generator.module, generator.method);\n\t\t}\n\t}\n\n\t/**\n\t * Add the server socket route generators.\n\t * @internal\n\t */\n\tprivate addServerSocketRouteGenerators(): void {\n\t\tfor (const generator of serverSocketRouteGenerators) {\n\t\t\tthis.addSocketRouteGenerator(generator.type, generator.module, generator.method);\n\t\t}\n\t}\n}\n"]}
|
package/dist/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qCAAqC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./engineServer.js\";\nexport * from \"./utils/engineServerConfigHelper.js\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engineServerConfigHelper.js","
|
|
1
|
+
{"version":3,"file":"engineServerConfigHelper.js","sources":["../../../src/utils/engineServerConfigHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAElC,OAAO,yBAAyB,MAAM,wCAAwC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACrG,OAAO,2BAA2B,MAAM,0CAA0C,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAEzG;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,YAAiC;IACpE,KAAK,MAAM,cAAc,IAAI,yBAAyB,EAAE,CAAC;QACxD,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAEtD,IACC,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC;YACpB,CAAC,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;YAClC,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,WAAW,CAAC,EACpC,CAAC;YACF,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,cAAc,CAAC,WAAW,CAAC;QAChD,CAAC;IACF,CAAC;AACF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,YAAiC;IACtE,KAAK,MAAM,cAAc,IAAI,2BAA2B,EAAE,CAAC;QAC1D,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAEtD,IACC,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC;YACpB,CAAC,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;YACpC,EAAE,CAAC,WAAW,CAAC,cAAc,CAAC,WAAW,CAAC,EACzC,CAAC;YACF,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,GAAG,cAAc,CAAC,WAAW,CAAC;QAClD,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Is } from \"@3sixty/core\";\nimport type { IEngineServerConfig } from \"@3sixty/engine-server-types\";\nimport serverRestRouteGenerators from \"../data/serverRestRouteGenerators.json\" with { type: \"json\" };\nimport serverSocketRouteGenerators from \"../data/serverSocketRouteGenerators.json\" with { type: \"json\" };\n\n/**\n * Adds the rest paths to the server config if not already set.\n * @param serverConfig The server config.\n */\nexport function addDefaultRestPaths(serverConfig: IEngineServerConfig): void {\n\tfor (const routeGenerator of serverRestRouteGenerators) {\n\t\tconst types = serverConfig.types[routeGenerator.type];\n\n\t\tif (\n\t\t\tIs.arrayValue(types) &&\n\t\t\t!Is.stringValue(types[0].restPath) &&\n\t\t\tIs.string(routeGenerator.defaultPath)\n\t\t) {\n\t\t\ttypes[0].restPath = routeGenerator.defaultPath;\n\t\t}\n\t}\n}\n\n/**\n * Adds the socket paths to the server config.\n * @param serverConfig The server config.\n */\nexport function addDefaultSocketPaths(serverConfig: IEngineServerConfig): void {\n\tfor (const routeGenerator of serverSocketRouteGenerators) {\n\t\tconst types = serverConfig.types[routeGenerator.type];\n\n\t\tif (\n\t\t\tIs.arrayValue(types) &&\n\t\t\t!Is.stringValue(types[0].socketPath) &&\n\t\t\tIs.stringValue(routeGenerator.defaultPath)\n\t\t) {\n\t\t\ttypes[0].socketPath = routeGenerator.defaultPath;\n\t\t}\n\t}\n}\n"]}
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.20.0-next.3](https://github.com/3sixtyglobal/engine/compare/engine-server-v0.20.0-next.2...engine-server-v0.20.0-next.3) (2026-10-26)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* release to next [skip ci] ([#26](https://github.com/3sixtyglobal/engine/issues/26)) ([958862b](https://github.com/3sixtyglobal/engine/commit/958862b3edebce6c07bd1f2237006ab19bab9e5c))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @3sixty/engine-models bumped from 0.20.0-next.2 to 0.20.0-next.3
|
|
16
|
+
* @3sixty/engine-server-types bumped from 0.20.0-next.2 to 0.20.0-next.3
|
|
17
|
+
* devDependencies
|
|
18
|
+
* @3sixty/engine bumped from 0.20.0-next.2 to 0.20.0-next.3
|
|
19
|
+
* @3sixty/engine-core bumped from 0.20.0-next.2 to 0.20.0-next.3
|
|
20
|
+
* @3sixty/engine-types bumped from 0.20.0-next.2 to 0.20.0-next.3
|
|
21
|
+
|
|
22
|
+
## [0.20.0-next.2](https://github.com/3sixtyglobal/engine/compare/engine-server-v0.20.0-next.1...engine-server-v0.20.0-next.2) (2026-10-23)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* add authorization ([#23](https://github.com/3sixtyglobal/engine/issues/23)) ([9815628](https://github.com/3sixtyglobal/engine/commit/9815628a7ef6cd79d1b7789c465447c7b29d90a8))
|
|
28
|
+
* updated ts compile ([2bfa964](https://github.com/3sixtyglobal/engine/commit/2bfa9642a97b35ee609c5e19d8bfe0571a1a6319))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Dependencies
|
|
32
|
+
|
|
33
|
+
* The following workspace dependencies were updated
|
|
34
|
+
* dependencies
|
|
35
|
+
* @3sixty/engine-models bumped from 0.20.0-next.1 to 0.20.0-next.2
|
|
36
|
+
* @3sixty/engine-server-types bumped from 0.20.0-next.1 to 0.20.0-next.2
|
|
37
|
+
* devDependencies
|
|
38
|
+
* @3sixty/engine bumped from 0.20.0-next.1 to 0.20.0-next.2
|
|
39
|
+
* @3sixty/engine-core bumped from 0.20.0-next.1 to 0.20.0-next.2
|
|
40
|
+
* @3sixty/engine-types bumped from 0.20.0-next.1 to 0.20.0-next.2
|
|
41
|
+
|
|
3
42
|
## [0.20.0-next.1](https://github.com/3sixtyglobal/engine/compare/engine-server-v0.20.0-next.0...engine-server-v0.20.0-next.1) (2026-10-21)
|
|
4
43
|
|
|
5
44
|
|
package/docs/examples.md
CHANGED
|
@@ -50,6 +50,28 @@ console.log(server.getRestRoutes().length > 0); // true
|
|
|
50
50
|
await server.stop();
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
+
## Web Server Type
|
|
54
|
+
|
|
55
|
+
Fastify is used by default, set `webServerType` to use Hono or the native Node.js server instead.
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import { Engine } from '@3sixty/engine';
|
|
59
|
+
import { EngineServer } from '@3sixty/engine-server';
|
|
60
|
+
import type { IEngineServerConfig } from '@3sixty/engine-server-types';
|
|
61
|
+
import { WebServerType } from '@3sixty/engine-server-types';
|
|
62
|
+
|
|
63
|
+
const config: IEngineServerConfig = {
|
|
64
|
+
webServerType: WebServerType.Hono,
|
|
65
|
+
web: { port: 3001 },
|
|
66
|
+
types: {}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const server = new EngineServer({ engineCore: new Engine({ config }) });
|
|
70
|
+
|
|
71
|
+
await server.start();
|
|
72
|
+
await server.stop();
|
|
73
|
+
```
|
|
74
|
+
|
|
53
75
|
## addDefaultRestPaths and addDefaultSocketPaths
|
|
54
76
|
|
|
55
77
|
```typescript
|
|
@@ -130,6 +130,10 @@ Get the built REST routes.
|
|
|
130
130
|
|
|
131
131
|
The REST routes.
|
|
132
132
|
|
|
133
|
+
#### Implementation of
|
|
134
|
+
|
|
135
|
+
`IEngineServer.getRestRoutes`
|
|
136
|
+
|
|
133
137
|
***
|
|
134
138
|
|
|
135
139
|
### getSocketRoutes() {#getsocketroutes}
|
|
@@ -144,6 +148,10 @@ Get the built socket routes.
|
|
|
144
148
|
|
|
145
149
|
The socket routes.
|
|
146
150
|
|
|
151
|
+
#### Implementation of
|
|
152
|
+
|
|
153
|
+
`IEngineServer.getSocketRoutes`
|
|
154
|
+
|
|
147
155
|
***
|
|
148
156
|
|
|
149
157
|
### start() {#start}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@3sixty/engine-server",
|
|
3
|
-
"version": "0.20.0-next.
|
|
3
|
+
"version": "0.20.0-next.3",
|
|
4
4
|
"description": "Server runtime that exposes engine components through REST and socket routes.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -11,15 +11,18 @@
|
|
|
11
11
|
"license": "Apache-2.0",
|
|
12
12
|
"type": "module",
|
|
13
13
|
"engines": {
|
|
14
|
-
"node": ">=24.0.0"
|
|
14
|
+
"node": ">=24.0.0",
|
|
15
|
+
"bun": ">=1.4.4"
|
|
15
16
|
},
|
|
16
17
|
"dependencies": {
|
|
17
18
|
"@3sixty/api-models": "next",
|
|
18
19
|
"@3sixty/api-server-fastify": "next",
|
|
20
|
+
"@3sixty/api-server-hono": "next",
|
|
21
|
+
"@3sixty/api-server-native": "next",
|
|
19
22
|
"@3sixty/context": "next",
|
|
20
23
|
"@3sixty/core": "next",
|
|
21
|
-
"@3sixty/engine-models": "0.20.0-next.
|
|
22
|
-
"@3sixty/engine-server-types": "0.20.0-next.
|
|
24
|
+
"@3sixty/engine-models": "0.20.0-next.3",
|
|
25
|
+
"@3sixty/engine-server-types": "0.20.0-next.3",
|
|
23
26
|
"@3sixty/modules": "next",
|
|
24
27
|
"@3sixty/nameof": "next"
|
|
25
28
|
},
|