@twin.org/engine-server 0.0.3-next.26 → 0.0.3-next.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/docs/changelog.md +19 -1
- package/docs/examples.md +79 -1
- package/docs/reference/classes/EngineServer.md +7 -7
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# TWIN Engine Server
|
|
2
2
|
|
|
3
|
-
Engine
|
|
3
|
+
Engine Server exposes runtime capabilities through REST and socket routes and integrates hosting concerns with engine orchestration. It is intended for service deployments that need structured API entry points backed by shared runtime conventions.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
package/docs/changelog.md
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.0.3-next.27](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.3-next.26...engine-server-v0.0.3-next.27) (2026-03-20)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* update dependencies ([e6ebe42](https://github.com/twinfoundation/engine/commit/e6ebe42b9d61066227ad8b45dae14c8f8615b760))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/engine-core bumped from 0.0.3-next.26 to 0.0.3-next.27
|
|
16
|
+
* @twin.org/engine-models bumped from 0.0.3-next.26 to 0.0.3-next.27
|
|
17
|
+
* @twin.org/engine-server-types bumped from 0.0.3-next.26 to 0.0.3-next.27
|
|
18
|
+
* devDependencies
|
|
19
|
+
* @twin.org/engine bumped from 0.0.3-next.26 to 0.0.3-next.27
|
|
2
20
|
|
|
3
21
|
## [0.0.3-next.26](https://github.com/twinfoundation/engine/compare/engine-server-v0.0.3-next.25...engine-server-v0.0.3-next.26) (2026-03-05)
|
|
4
22
|
|
package/docs/examples.md
CHANGED
|
@@ -1 +1,79 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Engine Server Examples
|
|
2
|
+
|
|
3
|
+
These examples show how to wire a core instance into an HTTP server and apply default REST and socket paths.
|
|
4
|
+
|
|
5
|
+
## EngineServer
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { Engine } from '@twin.org/engine';
|
|
9
|
+
import { EngineServer } from '@twin.org/engine-server';
|
|
10
|
+
import type { IEngineServerConfig } from '@twin.org/engine-server-types';
|
|
11
|
+
import {
|
|
12
|
+
HostingComponentType,
|
|
13
|
+
InformationComponentType,
|
|
14
|
+
RestRouteProcessorType,
|
|
15
|
+
SocketRouteProcessorType
|
|
16
|
+
} from '@twin.org/engine-server-types';
|
|
17
|
+
|
|
18
|
+
const config: IEngineServerConfig = {
|
|
19
|
+
debug: false,
|
|
20
|
+
silent: true,
|
|
21
|
+
web: { port: 3001 },
|
|
22
|
+
types: {
|
|
23
|
+
hostingComponent: [{ type: HostingComponentType.Service }],
|
|
24
|
+
informationComponent: [{ type: InformationComponentType.Service, restPath: '/info' }],
|
|
25
|
+
restRouteProcessor: [{ type: RestRouteProcessorType.RestRoute }],
|
|
26
|
+
socketRouteProcessor: [{ type: SocketRouteProcessorType.SocketRoute }]
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const engine = new Engine({ config, skipBootstrap: true });
|
|
31
|
+
const server = new EngineServer({ engineCore: engine });
|
|
32
|
+
|
|
33
|
+
server.addRestRouteGenerator(
|
|
34
|
+
'informationComponent',
|
|
35
|
+
'@twin.org/engine-server-types',
|
|
36
|
+
'generateInformationRestRoutes'
|
|
37
|
+
);
|
|
38
|
+
server.addSocketRouteGenerator(
|
|
39
|
+
'informationComponent',
|
|
40
|
+
'@twin.org/engine-server-types',
|
|
41
|
+
'generateInformationSocketRoutes'
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
console.log(server.getRestRoutes().length); // 0
|
|
45
|
+
console.log(server.getSocketRoutes().length); // 0
|
|
46
|
+
|
|
47
|
+
await server.start();
|
|
48
|
+
console.log(server.getRestRoutes().length > 0); // true
|
|
49
|
+
|
|
50
|
+
await server.stop();
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## addDefaultRestPaths and addDefaultSocketPaths
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
import { addDefaultRestPaths, addDefaultSocketPaths } from '@twin.org/engine-server';
|
|
57
|
+
import type { IEngineServerConfig } from '@twin.org/engine-server-types';
|
|
58
|
+
import {
|
|
59
|
+
InformationComponentType,
|
|
60
|
+
RestRouteProcessorType,
|
|
61
|
+
SocketRouteProcessorType
|
|
62
|
+
} from '@twin.org/engine-server-types';
|
|
63
|
+
|
|
64
|
+
const serverConfig: IEngineServerConfig = {
|
|
65
|
+
debug: false,
|
|
66
|
+
silent: false,
|
|
67
|
+
types: {
|
|
68
|
+
informationComponent: [{ type: InformationComponentType.Service }],
|
|
69
|
+
restRouteProcessor: [{ type: RestRouteProcessorType.RestRoute }],
|
|
70
|
+
socketRouteProcessor: [{ type: SocketRouteProcessorType.SocketRoute }]
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
addDefaultRestPaths(serverConfig);
|
|
75
|
+
addDefaultSocketPaths(serverConfig);
|
|
76
|
+
|
|
77
|
+
console.log(typeof serverConfig.types.informationComponent?.[0].restPath === 'string'); // true
|
|
78
|
+
console.log(typeof serverConfig.types.informationComponent?.[0].socketPath === 'string'); // true
|
|
79
|
+
```
|
|
@@ -38,7 +38,7 @@ The engine core to serve from.
|
|
|
38
38
|
|
|
39
39
|
## Properties
|
|
40
40
|
|
|
41
|
-
### CLASS\_NAME
|
|
41
|
+
### CLASS\_NAME {#class_name}
|
|
42
42
|
|
|
43
43
|
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
44
44
|
|
|
@@ -46,7 +46,7 @@ Runtime name for the class.
|
|
|
46
46
|
|
|
47
47
|
## Methods
|
|
48
48
|
|
|
49
|
-
### addRestRouteGenerator()
|
|
49
|
+
### addRestRouteGenerator() {#addrestroutegenerator}
|
|
50
50
|
|
|
51
51
|
> **addRestRouteGenerator**(`type`, `module`, `method`): `void`
|
|
52
52
|
|
|
@@ -82,7 +82,7 @@ The method to call on the module.
|
|
|
82
82
|
|
|
83
83
|
***
|
|
84
84
|
|
|
85
|
-
### addSocketRouteGenerator()
|
|
85
|
+
### addSocketRouteGenerator() {#addsocketroutegenerator}
|
|
86
86
|
|
|
87
87
|
> **addSocketRouteGenerator**(`type`, `module`, `method`): `void`
|
|
88
88
|
|
|
@@ -118,7 +118,7 @@ The method to call on the module.
|
|
|
118
118
|
|
|
119
119
|
***
|
|
120
120
|
|
|
121
|
-
### getRestRoutes()
|
|
121
|
+
### getRestRoutes() {#getrestroutes}
|
|
122
122
|
|
|
123
123
|
> **getRestRoutes**(): `IRestRoute`\<`any`, `any`\>[]
|
|
124
124
|
|
|
@@ -132,7 +132,7 @@ The REST routes.
|
|
|
132
132
|
|
|
133
133
|
***
|
|
134
134
|
|
|
135
|
-
### getSocketRoutes()
|
|
135
|
+
### getSocketRoutes() {#getsocketroutes}
|
|
136
136
|
|
|
137
137
|
> **getSocketRoutes**(): `ISocketRoute`\<`any`, `any`\>[]
|
|
138
138
|
|
|
@@ -146,7 +146,7 @@ The socket routes.
|
|
|
146
146
|
|
|
147
147
|
***
|
|
148
148
|
|
|
149
|
-
### start()
|
|
149
|
+
### start() {#start}
|
|
150
150
|
|
|
151
151
|
> **start**(): `Promise`\<`void`\>
|
|
152
152
|
|
|
@@ -164,7 +164,7 @@ Nothing.
|
|
|
164
164
|
|
|
165
165
|
***
|
|
166
166
|
|
|
167
|
-
### stop()
|
|
167
|
+
### stop() {#stop}
|
|
168
168
|
|
|
169
169
|
> **stop**(): `Promise`\<`void`\>
|
|
170
170
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/engine-server",
|
|
3
|
-
"version": "0.0.3-next.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.0.3-next.27",
|
|
4
|
+
"description": "Server runtime that exposes engine components through REST and socket routes.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/twinfoundation/engine.git",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"@twin.org/api-server-fastify": "next",
|
|
19
19
|
"@twin.org/context": "next",
|
|
20
20
|
"@twin.org/core": "next",
|
|
21
|
-
"@twin.org/engine-core": "0.0.3-next.
|
|
22
|
-
"@twin.org/engine-models": "0.0.3-next.
|
|
23
|
-
"@twin.org/engine-server-types": "0.0.3-next.
|
|
21
|
+
"@twin.org/engine-core": "0.0.3-next.27",
|
|
22
|
+
"@twin.org/engine-models": "0.0.3-next.27",
|
|
23
|
+
"@twin.org/engine-server-types": "0.0.3-next.27",
|
|
24
24
|
"@twin.org/modules": "next",
|
|
25
25
|
"@twin.org/nameof": "next"
|
|
26
26
|
},
|