@twin.org/api-service 0.0.3-next.20 → 0.0.3-next.22

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # TWIN API Service
2
2
 
3
- Implementation of the information service.
3
+ This package provides information and hosting service implementations with generated REST route handlers.
4
4
 
5
5
  ## Installation
6
6
 
package/docs/changelog.md CHANGED
@@ -1,4 +1,32 @@
1
- # @twin.org/api-service - Changelog
1
+ # Changelog
2
+
3
+ ## [0.0.3-next.22](https://github.com/twinfoundation/api/compare/api-service-v0.0.3-next.21...api-service-v0.0.3-next.22) (2026-03-27)
4
+
5
+
6
+ ### Miscellaneous Chores
7
+
8
+ * **api-service:** Synchronize repo versions
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/api-models bumped from 0.0.3-next.21 to 0.0.3-next.22
16
+
17
+ ## [0.0.3-next.21](https://github.com/twinfoundation/api/compare/api-service-v0.0.3-next.20...api-service-v0.0.3-next.21) (2026-03-11)
18
+
19
+
20
+ ### Miscellaneous Chores
21
+
22
+ * **api-service:** Synchronize repo versions
23
+
24
+
25
+ ### Dependencies
26
+
27
+ * The following workspace dependencies were updated
28
+ * dependencies
29
+ * @twin.org/api-models bumped from 0.0.3-next.20 to 0.0.3-next.21
2
30
 
3
31
  ## [0.0.3-next.20](https://github.com/twinfoundation/api/compare/api-service-v0.0.3-next.19...api-service-v0.0.3-next.20) (2026-02-09)
4
32
 
package/docs/examples.md CHANGED
@@ -1 +1,74 @@
1
- # @twin.org/api-service - Examples
1
+ # Service Examples
2
+
3
+ These snippets demonstrate how to configure service-level URL generation and expose operational information for monitoring.
4
+
5
+ ## InformationService
6
+
7
+ ```typescript
8
+ import { InformationService } from '@twin.org/api-service';
9
+
10
+ const infoService = new InformationService({
11
+ config: {
12
+ serverInfo: {
13
+ name: 'Twin API',
14
+ version: '1.2.0'
15
+ }
16
+ }
17
+ });
18
+
19
+ await infoService.start();
20
+ console.log(infoService.className()); // InformationService
21
+
22
+ const root = await infoService.root();
23
+ const info = await infoService.info();
24
+ const favicon = await infoService.favicon();
25
+
26
+ console.log(root); // Twin API - 1.2.0
27
+ console.log(info.version); // 1.2.0
28
+ console.log((favicon?.byteLength ?? 0) > 0); // true
29
+ ```
30
+
31
+ ```typescript
32
+ import { InformationService } from '@twin.org/api-service';
33
+
34
+ const infoService = new InformationService({
35
+ config: {
36
+ serverInfo: {
37
+ name: 'Twin API',
38
+ version: '1.2.0'
39
+ }
40
+ }
41
+ });
42
+
43
+ const spec = await infoService.spec();
44
+ const live = await infoService.livez();
45
+ const health = await infoService.health();
46
+
47
+ await infoService.setComponentHealth('queue', 'ok');
48
+ await infoService.removeComponentHealth('queue');
49
+
50
+ console.log(typeof spec); // undefined
51
+ console.log(live); // true
52
+ console.log(health.status); // ok
53
+ ```
54
+
55
+ ## HostingService
56
+
57
+ ```typescript
58
+ import { HostingService } from '@twin.org/api-service';
59
+
60
+ const hostingService = new HostingService({
61
+ config: {
62
+ localOrigin: 'http://localhost:3000',
63
+ publicOrigin: 'https://api.example.org'
64
+ }
65
+ });
66
+
67
+ console.log(hostingService.className()); // HostingService
68
+
69
+ const publicOrigin = await hostingService.getPublicOrigin('http://localhost:3000/users');
70
+ const usersUrl = await hostingService.buildPublicUrl('http://localhost:3000/users');
71
+
72
+ console.log(publicOrigin); // https://api.example.org
73
+ console.log(usersUrl); // https://api.example.org/users
74
+ ```
@@ -28,7 +28,7 @@ The options to create the service.
28
28
 
29
29
  ## Properties
30
30
 
31
- ### CLASS\_NAME
31
+ ### CLASS\_NAME {#class_name}
32
32
 
33
33
  > `readonly` `static` **CLASS\_NAME**: `string`
34
34
 
@@ -36,7 +36,7 @@ Runtime name for the class.
36
36
 
37
37
  ## Methods
38
38
 
39
- ### className()
39
+ ### className() {#classname}
40
40
 
41
41
  > **className**(): `string`
42
42
 
@@ -54,7 +54,7 @@ The class name of the component.
54
54
 
55
55
  ***
56
56
 
57
- ### getPublicOrigin()
57
+ ### getPublicOrigin() {#getpublicorigin}
58
58
 
59
59
  > **getPublicOrigin**(`serverRequestUrl?`): `Promise`\<`string`\>
60
60
 
@@ -80,7 +80,7 @@ The public origin.
80
80
 
81
81
  ***
82
82
 
83
- ### getTenantOrigin()
83
+ ### getTenantOrigin() {#gettenantorigin}
84
84
 
85
85
  > **getTenantOrigin**(`tenantId`): `Promise`\<`string` \| `undefined`\>
86
86
 
@@ -106,7 +106,7 @@ The public origin for the tenant.
106
106
 
107
107
  ***
108
108
 
109
- ### buildPublicUrl()
109
+ ### buildPublicUrl() {#buildpublicurl}
110
110
 
111
111
  > **buildPublicUrl**(`url`): `Promise`\<`string`\>
112
112
 
@@ -28,7 +28,7 @@ The options to create the service.
28
28
 
29
29
  ## Properties
30
30
 
31
- ### CLASS\_NAME
31
+ ### CLASS\_NAME {#class_name}
32
32
 
33
33
  > `readonly` `static` **CLASS\_NAME**: `string`
34
34
 
@@ -36,7 +36,7 @@ Runtime name for the class.
36
36
 
37
37
  ## Methods
38
38
 
39
- ### className()
39
+ ### className() {#classname}
40
40
 
41
41
  > **className**(): `string`
42
42
 
@@ -54,7 +54,7 @@ The class name of the component.
54
54
 
55
55
  ***
56
56
 
57
- ### start()
57
+ ### start() {#start}
58
58
 
59
59
  > **start**(): `Promise`\<`void`\>
60
60
 
@@ -72,7 +72,7 @@ Nothing.
72
72
 
73
73
  ***
74
74
 
75
- ### root()
75
+ ### root() {#root}
76
76
 
77
77
  > **root**(): `Promise`\<`string`\>
78
78
 
@@ -90,7 +90,7 @@ The root information.
90
90
 
91
91
  ***
92
92
 
93
- ### info()
93
+ ### info() {#info}
94
94
 
95
95
  > **info**(): `Promise`\<`IServerInfo`\>
96
96
 
@@ -108,7 +108,7 @@ The service information.
108
108
 
109
109
  ***
110
110
 
111
- ### favicon()
111
+ ### favicon() {#favicon}
112
112
 
113
113
  > **favicon**(): `Promise`\<`Uint8Array`\<`ArrayBufferLike`\> \| `undefined`\>
114
114
 
@@ -126,7 +126,7 @@ The favicon.
126
126
 
127
127
  ***
128
128
 
129
- ### spec()
129
+ ### spec() {#spec}
130
130
 
131
131
  > **spec**(): `Promise`\<`unknown`\>
132
132
 
@@ -144,7 +144,7 @@ The OpenAPI spec.
144
144
 
145
145
  ***
146
146
 
147
- ### livez()
147
+ ### livez() {#livez}
148
148
 
149
149
  > **livez**(): `Promise`\<`boolean`\>
150
150
 
@@ -162,7 +162,7 @@ True if the server is live.
162
162
 
163
163
  ***
164
164
 
165
- ### health()
165
+ ### health() {#health}
166
166
 
167
167
  > **health**(): `Promise`\<`IHealthInfo`\>
168
168
 
@@ -180,7 +180,7 @@ The service health.
180
180
 
181
181
  ***
182
182
 
183
- ### setComponentHealth()
183
+ ### setComponentHealth() {#setcomponenthealth}
184
184
 
185
185
  > **setComponentHealth**(`name`, `status`, `details?`, `tenantId?`): `Promise`\<`void`\>
186
186
 
@@ -224,7 +224,7 @@ Nothing.
224
224
 
225
225
  ***
226
226
 
227
- ### removeComponentHealth()
227
+ ### removeComponentHealth() {#removecomponenthealth}
228
228
 
229
229
  > **removeComponentHealth**(`name`, `tenantId?`): `Promise`\<`void`\>
230
230
 
@@ -4,7 +4,7 @@ Configuration for the hosting service.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### localOrigin
7
+ ### localOrigin {#localorigin}
8
8
 
9
9
  > **localOrigin**: `string`
10
10
 
@@ -12,8 +12,8 @@ The local origin, must be provided as a fallback e.g. http://localhost:1234.
12
12
 
13
13
  ***
14
14
 
15
- ### publicOrigin?
15
+ ### publicOrigin? {#publicorigin}
16
16
 
17
- > `optional` **publicOrigin**: `string`
17
+ > `optional` **publicOrigin?**: `string`
18
18
 
19
19
  The APIs public base URL e.g. "https://api.example.com:1234".
@@ -4,9 +4,9 @@ Options for the IHostingService constructor.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### tenantAdminComponentType?
7
+ ### tenantAdminComponentType? {#tenantadmincomponenttype}
8
8
 
9
- > `optional` **tenantAdminComponentType**: `string`
9
+ > `optional` **tenantAdminComponentType?**: `string`
10
10
 
11
11
  The tenant admin component type.
12
12
 
@@ -18,7 +18,7 @@ tenant-admin
18
18
 
19
19
  ***
20
20
 
21
- ### config
21
+ ### config {#config}
22
22
 
23
23
  > **config**: [`IHostingServiceConfig`](IHostingServiceConfig.md)
24
24
 
@@ -4,7 +4,7 @@ Configuration for the information service.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### serverInfo
7
+ ### serverInfo {#serverinfo}
8
8
 
9
9
  > **serverInfo**: `IServerInfo`
10
10
 
@@ -12,16 +12,16 @@ The server information.
12
12
 
13
13
  ***
14
14
 
15
- ### openApiSpecPath?
15
+ ### openApiSpecPath? {#openapispecpath}
16
16
 
17
- > `optional` **openApiSpecPath**: `string`
17
+ > `optional` **openApiSpecPath?**: `string`
18
18
 
19
19
  The path to the OpenAPI Spec.
20
20
 
21
21
  ***
22
22
 
23
- ### favIconPath?
23
+ ### favIconPath? {#faviconpath}
24
24
 
25
- > `optional` **favIconPath**: `string`
25
+ > `optional` **favIconPath?**: `string`
26
26
 
27
27
  The path to the favicon.
@@ -4,7 +4,7 @@ Options for the InformationService constructor.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### config
7
+ ### config {#config}
8
8
 
9
9
  > **config**: [`IInformationServiceConfig`](IInformationServiceConfig.md)
10
10
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@twin.org/api-service",
3
- "version": "0.0.3-next.20",
4
- "description": "Information contract implementation and REST endpoint definitions",
3
+ "version": "0.0.3-next.22",
4
+ "description": "Information and hosting service implementations with generated REST route handlers.",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/twinfoundation/api.git",
@@ -14,7 +14,7 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/api-models": "0.0.3-next.20",
17
+ "@twin.org/api-models": "0.0.3-next.22",
18
18
  "@twin.org/context": "next",
19
19
  "@twin.org/core": "next",
20
20
  "@twin.org/nameof": "next",