@twin.org/api-service 0.0.3-next.2 → 0.0.3-next.21
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/dist/es/hostingService.js +94 -0
- package/dist/es/hostingService.js.map +1 -0
- package/dist/es/index.js +3 -0
- package/dist/es/index.js.map +1 -1
- package/dist/es/informationRoutes.js +65 -3
- package/dist/es/informationRoutes.js.map +1 -1
- package/dist/es/informationService.js +39 -9
- package/dist/es/informationService.js.map +1 -1
- package/dist/es/models/IHostingServiceConfig.js +4 -0
- package/dist/es/models/IHostingServiceConfig.js.map +1 -0
- package/dist/es/models/IHostingServiceConstructorOptions.js +2 -0
- package/dist/es/models/IHostingServiceConstructorOptions.js.map +1 -0
- package/dist/types/hostingService.d.ts +39 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/informationRoutes.d.ts +9 -1
- package/dist/types/informationService.d.ts +9 -2
- package/dist/types/models/IHostingServiceConfig.d.ts +13 -0
- package/dist/types/models/IHostingServiceConstructorOptions.d.ts +15 -0
- package/docs/changelog.md +284 -1
- package/docs/examples.md +74 -1
- package/docs/reference/classes/HostingService.md +131 -0
- package/docs/reference/classes/InformationService.md +32 -2
- package/docs/reference/functions/serverLivez.md +31 -0
- package/docs/reference/index.md +4 -0
- package/docs/reference/interfaces/IHostingServiceConfig.md +19 -0
- package/docs/reference/interfaces/IHostingServiceConstructorOptions.md +19 -0
- package/package.json +4 -3
package/docs/changelog.md
CHANGED
|
@@ -1,4 +1,287 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [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)
|
|
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.20 to 0.0.3-next.21
|
|
16
|
+
|
|
17
|
+
## [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)
|
|
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.19 to 0.0.3-next.20
|
|
30
|
+
|
|
31
|
+
## [0.0.3-next.19](https://github.com/twinfoundation/api/compare/api-service-v0.0.3-next.18...api-service-v0.0.3-next.19) (2026-02-06)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Miscellaneous Chores
|
|
35
|
+
|
|
36
|
+
* **api-service:** Synchronize repo versions
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Dependencies
|
|
40
|
+
|
|
41
|
+
* The following workspace dependencies were updated
|
|
42
|
+
* dependencies
|
|
43
|
+
* @twin.org/api-models bumped from 0.0.3-next.18 to 0.0.3-next.19
|
|
44
|
+
|
|
45
|
+
## [0.0.3-next.18](https://github.com/twinfoundation/api/compare/api-service-v0.0.3-next.17...api-service-v0.0.3-next.18) (2026-02-04)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
### Miscellaneous Chores
|
|
49
|
+
|
|
50
|
+
* **api-service:** Synchronize repo versions
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
### Dependencies
|
|
54
|
+
|
|
55
|
+
* The following workspace dependencies were updated
|
|
56
|
+
* dependencies
|
|
57
|
+
* @twin.org/api-models bumped from 0.0.3-next.17 to 0.0.3-next.18
|
|
58
|
+
|
|
59
|
+
## [0.0.3-next.17](https://github.com/twinfoundation/api/compare/api-service-v0.0.3-next.16...api-service-v0.0.3-next.17) (2026-01-26)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
### Features
|
|
63
|
+
|
|
64
|
+
* update public origin building ([6c8e042](https://github.com/twinfoundation/api/commit/6c8e0422d9ddbed42a843e1c23498c99977b2fc7))
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
### Dependencies
|
|
68
|
+
|
|
69
|
+
* The following workspace dependencies were updated
|
|
70
|
+
* dependencies
|
|
71
|
+
* @twin.org/api-models bumped from 0.0.3-next.16 to 0.0.3-next.17
|
|
72
|
+
|
|
73
|
+
## [0.0.3-next.16](https://github.com/twinfoundation/api/compare/api-service-v0.0.3-next.15...api-service-v0.0.3-next.16) (2026-01-26)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
### Features
|
|
77
|
+
|
|
78
|
+
* public base url ([#70](https://github.com/twinfoundation/api/issues/70)) ([5b958cd](https://github.com/twinfoundation/api/commit/5b958cd91e8a38cdae2835ff5f2356c7e48d37c3))
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
### Dependencies
|
|
82
|
+
|
|
83
|
+
* The following workspace dependencies were updated
|
|
84
|
+
* dependencies
|
|
85
|
+
* @twin.org/api-models bumped from 0.0.3-next.15 to 0.0.3-next.16
|
|
86
|
+
|
|
87
|
+
## [0.0.3-next.15](https://github.com/twinfoundation/api/compare/api-service-v0.0.3-next.14...api-service-v0.0.3-next.15) (2026-01-22)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
### Miscellaneous Chores
|
|
91
|
+
|
|
92
|
+
* **api-service:** Synchronize repo versions
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
### Dependencies
|
|
96
|
+
|
|
97
|
+
* The following workspace dependencies were updated
|
|
98
|
+
* dependencies
|
|
99
|
+
* @twin.org/api-models bumped from 0.0.3-next.14 to 0.0.3-next.15
|
|
100
|
+
|
|
101
|
+
## [0.0.3-next.14](https://github.com/twinfoundation/api/compare/api-service-v0.0.3-next.13...api-service-v0.0.3-next.14) (2026-01-20)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
### Miscellaneous Chores
|
|
105
|
+
|
|
106
|
+
* **api-service:** Synchronize repo versions
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
### Dependencies
|
|
110
|
+
|
|
111
|
+
* The following workspace dependencies were updated
|
|
112
|
+
* dependencies
|
|
113
|
+
* @twin.org/api-models bumped from 0.0.3-next.13 to 0.0.3-next.14
|
|
114
|
+
|
|
115
|
+
## [0.0.3-next.13](https://github.com/twinfoundation/api/compare/api-service-v0.0.3-next.12...api-service-v0.0.3-next.13) (2026-01-19)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
### Miscellaneous Chores
|
|
119
|
+
|
|
120
|
+
* **api-service:** Synchronize repo versions
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
### Dependencies
|
|
124
|
+
|
|
125
|
+
* The following workspace dependencies were updated
|
|
126
|
+
* dependencies
|
|
127
|
+
* @twin.org/api-models bumped from 0.0.3-next.12 to 0.0.3-next.13
|
|
128
|
+
|
|
129
|
+
## [0.0.3-next.12](https://github.com/twinfoundation/api/compare/api-service-v0.0.3-next.11...api-service-v0.0.3-next.12) (2026-01-12)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
### Miscellaneous Chores
|
|
133
|
+
|
|
134
|
+
* **api-service:** Synchronize repo versions
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
### Dependencies
|
|
138
|
+
|
|
139
|
+
* The following workspace dependencies were updated
|
|
140
|
+
* dependencies
|
|
141
|
+
* @twin.org/api-models bumped from 0.0.3-next.11 to 0.0.3-next.12
|
|
142
|
+
|
|
143
|
+
## [0.0.3-next.11](https://github.com/twinfoundation/api/compare/api-service-v0.0.3-next.10...api-service-v0.0.3-next.11) (2026-01-08)
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
### Miscellaneous Chores
|
|
147
|
+
|
|
148
|
+
* **api-service:** Synchronize repo versions
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
### Dependencies
|
|
152
|
+
|
|
153
|
+
* The following workspace dependencies were updated
|
|
154
|
+
* dependencies
|
|
155
|
+
* @twin.org/api-models bumped from 0.0.3-next.10 to 0.0.3-next.11
|
|
156
|
+
|
|
157
|
+
## [0.0.3-next.10](https://github.com/twinfoundation/api/compare/api-service-v0.0.3-next.9...api-service-v0.0.3-next.10) (2026-01-05)
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
### Miscellaneous Chores
|
|
161
|
+
|
|
162
|
+
* **api-service:** Synchronize repo versions
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
### Dependencies
|
|
166
|
+
|
|
167
|
+
* The following workspace dependencies were updated
|
|
168
|
+
* dependencies
|
|
169
|
+
* @twin.org/api-models bumped from 0.0.3-next.9 to 0.0.3-next.10
|
|
170
|
+
|
|
171
|
+
## [0.0.3-next.9](https://github.com/twinfoundation/api/compare/api-service-v0.0.3-next.8...api-service-v0.0.3-next.9) (2026-01-05)
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
### Features
|
|
175
|
+
|
|
176
|
+
* add context id features ([#42](https://github.com/twinfoundation/api/issues/42)) ([0186055](https://github.com/twinfoundation/api/commit/0186055c48afde842a4254b4df9ac9249c40fe40))
|
|
177
|
+
* add livez endpoint ([#57](https://github.com/twinfoundation/api/issues/57)) ([ef007db](https://github.com/twinfoundation/api/commit/ef007db8201736dd3053211f849ffd03baaa485e))
|
|
178
|
+
* add root, favicon routes ([71da1c3](https://github.com/twinfoundation/api/commit/71da1c3a93c349588aff7084d1d8d6a29a277da8))
|
|
179
|
+
* add validate-locales ([cdba610](https://github.com/twinfoundation/api/commit/cdba610a0acb5022d2e3ce729732e6646a297e5e))
|
|
180
|
+
* eslint migration to flat config ([0dd5820](https://github.com/twinfoundation/api/commit/0dd5820e3af97350fd08b8d226f4a6c1a9246805))
|
|
181
|
+
* remove unused namespace ([08478f2](https://github.com/twinfoundation/api/commit/08478f27efda9beb0271fdb22f6972e918361965))
|
|
182
|
+
* update dependencies ([1171dc4](https://github.com/twinfoundation/api/commit/1171dc416a9481737f6a640e3cf30145768f37e9))
|
|
183
|
+
* update framework core ([d8eebf2](https://github.com/twinfoundation/api/commit/d8eebf267fa2a0abaa84e58590496e9d20490cfa))
|
|
184
|
+
* update IComponent signatures ([915ce37](https://github.com/twinfoundation/api/commit/915ce37712326ab4aa6869c350eabaa4622e8430))
|
|
185
|
+
* use shared store mechanism ([#19](https://github.com/twinfoundation/api/issues/19)) ([32116df](https://github.com/twinfoundation/api/commit/32116df3b4380a30137f5056f242a5c99afa2df9))
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
### Dependencies
|
|
189
|
+
|
|
190
|
+
* The following workspace dependencies were updated
|
|
191
|
+
* dependencies
|
|
192
|
+
* @twin.org/api-models bumped from 0.0.3-next.8 to 0.0.3-next.9
|
|
193
|
+
|
|
194
|
+
## [0.0.3-next.8](https://github.com/twinfoundation/api/compare/api-service-v0.0.3-next.7...api-service-v0.0.3-next.8) (2025-12-17)
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
### Miscellaneous Chores
|
|
198
|
+
|
|
199
|
+
* **api-service:** Synchronize repo versions
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
### Dependencies
|
|
203
|
+
|
|
204
|
+
* The following workspace dependencies were updated
|
|
205
|
+
* dependencies
|
|
206
|
+
* @twin.org/api-models bumped from 0.0.3-next.7 to 0.0.3-next.8
|
|
207
|
+
|
|
208
|
+
## [0.0.3-next.7](https://github.com/twinfoundation/api/compare/api-service-v0.0.3-next.6...api-service-v0.0.3-next.7) (2025-11-26)
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
### Miscellaneous Chores
|
|
212
|
+
|
|
213
|
+
* **api-service:** Synchronize repo versions
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
### Dependencies
|
|
217
|
+
|
|
218
|
+
* The following workspace dependencies were updated
|
|
219
|
+
* dependencies
|
|
220
|
+
* @twin.org/api-models bumped from 0.0.3-next.6 to 0.0.3-next.7
|
|
221
|
+
|
|
222
|
+
## [0.0.3-next.6](https://github.com/twinfoundation/api/compare/api-service-v0.0.3-next.5...api-service-v0.0.3-next.6) (2025-11-20)
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
### Miscellaneous Chores
|
|
226
|
+
|
|
227
|
+
* **api-service:** Synchronize repo versions
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
### Dependencies
|
|
231
|
+
|
|
232
|
+
* The following workspace dependencies were updated
|
|
233
|
+
* dependencies
|
|
234
|
+
* @twin.org/api-models bumped from 0.0.3-next.5 to 0.0.3-next.6
|
|
235
|
+
|
|
236
|
+
## [0.0.3-next.5](https://github.com/twinfoundation/api/compare/api-service-v0.0.3-next.4...api-service-v0.0.3-next.5) (2025-11-14)
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
### Miscellaneous Chores
|
|
240
|
+
|
|
241
|
+
* **api-service:** Synchronize repo versions
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
### Dependencies
|
|
245
|
+
|
|
246
|
+
* The following workspace dependencies were updated
|
|
247
|
+
* dependencies
|
|
248
|
+
* @twin.org/api-models bumped from 0.0.3-next.4 to 0.0.3-next.5
|
|
249
|
+
|
|
250
|
+
## [0.0.3-next.4](https://github.com/twinfoundation/api/compare/api-service-v0.0.3-next.3...api-service-v0.0.3-next.4) (2025-11-14)
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
### Features
|
|
254
|
+
|
|
255
|
+
* add context id features ([#42](https://github.com/twinfoundation/api/issues/42)) ([0186055](https://github.com/twinfoundation/api/commit/0186055c48afde842a4254b4df9ac9249c40fe40))
|
|
256
|
+
* add root, favicon routes ([71da1c3](https://github.com/twinfoundation/api/commit/71da1c3a93c349588aff7084d1d8d6a29a277da8))
|
|
257
|
+
* add validate-locales ([cdba610](https://github.com/twinfoundation/api/commit/cdba610a0acb5022d2e3ce729732e6646a297e5e))
|
|
258
|
+
* eslint migration to flat config ([0dd5820](https://github.com/twinfoundation/api/commit/0dd5820e3af97350fd08b8d226f4a6c1a9246805))
|
|
259
|
+
* remove unused namespace ([08478f2](https://github.com/twinfoundation/api/commit/08478f27efda9beb0271fdb22f6972e918361965))
|
|
260
|
+
* update dependencies ([1171dc4](https://github.com/twinfoundation/api/commit/1171dc416a9481737f6a640e3cf30145768f37e9))
|
|
261
|
+
* update framework core ([d8eebf2](https://github.com/twinfoundation/api/commit/d8eebf267fa2a0abaa84e58590496e9d20490cfa))
|
|
262
|
+
* update IComponent signatures ([915ce37](https://github.com/twinfoundation/api/commit/915ce37712326ab4aa6869c350eabaa4622e8430))
|
|
263
|
+
* use shared store mechanism ([#19](https://github.com/twinfoundation/api/issues/19)) ([32116df](https://github.com/twinfoundation/api/commit/32116df3b4380a30137f5056f242a5c99afa2df9))
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
### Dependencies
|
|
267
|
+
|
|
268
|
+
* The following workspace dependencies were updated
|
|
269
|
+
* dependencies
|
|
270
|
+
* @twin.org/api-models bumped from 0.0.3-next.3 to 0.0.3-next.4
|
|
271
|
+
|
|
272
|
+
## [0.0.3-next.3](https://github.com/twinfoundation/api/compare/api-service-v0.0.3-next.2...api-service-v0.0.3-next.3) (2025-11-14)
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
### Miscellaneous Chores
|
|
276
|
+
|
|
277
|
+
* **api-service:** Synchronize repo versions
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
### Dependencies
|
|
281
|
+
|
|
282
|
+
* The following workspace dependencies were updated
|
|
283
|
+
* dependencies
|
|
284
|
+
* @twin.org/api-models bumped from 0.0.3-next.2 to 0.0.3-next.3
|
|
2
285
|
|
|
3
286
|
## [0.0.3-next.2](https://github.com/twinfoundation/api/compare/api-service-v0.0.3-next.1...api-service-v0.0.3-next.2) (2025-11-12)
|
|
4
287
|
|
package/docs/examples.md
CHANGED
|
@@ -1 +1,74 @@
|
|
|
1
|
-
#
|
|
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
|
+
```
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# Class: HostingService
|
|
2
|
+
|
|
3
|
+
The hosting service for the server.
|
|
4
|
+
|
|
5
|
+
## Implements
|
|
6
|
+
|
|
7
|
+
- `IHostingComponent`
|
|
8
|
+
|
|
9
|
+
## Constructors
|
|
10
|
+
|
|
11
|
+
### Constructor
|
|
12
|
+
|
|
13
|
+
> **new HostingService**(`options`): `HostingService`
|
|
14
|
+
|
|
15
|
+
Create a new instance of HostingService.
|
|
16
|
+
|
|
17
|
+
#### Parameters
|
|
18
|
+
|
|
19
|
+
##### options
|
|
20
|
+
|
|
21
|
+
[`IHostingServiceConstructorOptions`](../interfaces/IHostingServiceConstructorOptions.md)
|
|
22
|
+
|
|
23
|
+
The options to create the service.
|
|
24
|
+
|
|
25
|
+
#### Returns
|
|
26
|
+
|
|
27
|
+
`HostingService`
|
|
28
|
+
|
|
29
|
+
## Properties
|
|
30
|
+
|
|
31
|
+
### CLASS\_NAME
|
|
32
|
+
|
|
33
|
+
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
34
|
+
|
|
35
|
+
Runtime name for the class.
|
|
36
|
+
|
|
37
|
+
## Methods
|
|
38
|
+
|
|
39
|
+
### className()
|
|
40
|
+
|
|
41
|
+
> **className**(): `string`
|
|
42
|
+
|
|
43
|
+
Returns the class name of the component.
|
|
44
|
+
|
|
45
|
+
#### Returns
|
|
46
|
+
|
|
47
|
+
`string`
|
|
48
|
+
|
|
49
|
+
The class name of the component.
|
|
50
|
+
|
|
51
|
+
#### Implementation of
|
|
52
|
+
|
|
53
|
+
`IHostingComponent.className`
|
|
54
|
+
|
|
55
|
+
***
|
|
56
|
+
|
|
57
|
+
### getPublicOrigin()
|
|
58
|
+
|
|
59
|
+
> **getPublicOrigin**(`serverRequestUrl?`): `Promise`\<`string`\>
|
|
60
|
+
|
|
61
|
+
Get the public origin for the hosting.
|
|
62
|
+
|
|
63
|
+
#### Parameters
|
|
64
|
+
|
|
65
|
+
##### serverRequestUrl?
|
|
66
|
+
|
|
67
|
+
`string`
|
|
68
|
+
|
|
69
|
+
The url of the current server request if there is one.
|
|
70
|
+
|
|
71
|
+
#### Returns
|
|
72
|
+
|
|
73
|
+
`Promise`\<`string`\>
|
|
74
|
+
|
|
75
|
+
The public origin.
|
|
76
|
+
|
|
77
|
+
#### Implementation of
|
|
78
|
+
|
|
79
|
+
`IHostingComponent.getPublicOrigin`
|
|
80
|
+
|
|
81
|
+
***
|
|
82
|
+
|
|
83
|
+
### getTenantOrigin()
|
|
84
|
+
|
|
85
|
+
> **getTenantOrigin**(`tenantId`): `Promise`\<`string` \| `undefined`\>
|
|
86
|
+
|
|
87
|
+
Get the public origin for the tenant if one exists.
|
|
88
|
+
|
|
89
|
+
#### Parameters
|
|
90
|
+
|
|
91
|
+
##### tenantId
|
|
92
|
+
|
|
93
|
+
`string`
|
|
94
|
+
|
|
95
|
+
The tenant identifier.
|
|
96
|
+
|
|
97
|
+
#### Returns
|
|
98
|
+
|
|
99
|
+
`Promise`\<`string` \| `undefined`\>
|
|
100
|
+
|
|
101
|
+
The public origin for the tenant.
|
|
102
|
+
|
|
103
|
+
#### Implementation of
|
|
104
|
+
|
|
105
|
+
`IHostingComponent.getTenantOrigin`
|
|
106
|
+
|
|
107
|
+
***
|
|
108
|
+
|
|
109
|
+
### buildPublicUrl()
|
|
110
|
+
|
|
111
|
+
> **buildPublicUrl**(`url`): `Promise`\<`string`\>
|
|
112
|
+
|
|
113
|
+
Build a public url based on the public origin and the url provided.
|
|
114
|
+
|
|
115
|
+
#### Parameters
|
|
116
|
+
|
|
117
|
+
##### url
|
|
118
|
+
|
|
119
|
+
`string`
|
|
120
|
+
|
|
121
|
+
The url to build upon the public origin.
|
|
122
|
+
|
|
123
|
+
#### Returns
|
|
124
|
+
|
|
125
|
+
`Promise`\<`string`\>
|
|
126
|
+
|
|
127
|
+
The full url based on the public origin.
|
|
128
|
+
|
|
129
|
+
#### Implementation of
|
|
130
|
+
|
|
131
|
+
`IHostingComponent.buildPublicUrl`
|
|
@@ -144,6 +144,24 @@ The OpenAPI spec.
|
|
|
144
144
|
|
|
145
145
|
***
|
|
146
146
|
|
|
147
|
+
### livez()
|
|
148
|
+
|
|
149
|
+
> **livez**(): `Promise`\<`boolean`\>
|
|
150
|
+
|
|
151
|
+
Is the server live.
|
|
152
|
+
|
|
153
|
+
#### Returns
|
|
154
|
+
|
|
155
|
+
`Promise`\<`boolean`\>
|
|
156
|
+
|
|
157
|
+
True if the server is live.
|
|
158
|
+
|
|
159
|
+
#### Implementation of
|
|
160
|
+
|
|
161
|
+
`IInformationComponent.livez`
|
|
162
|
+
|
|
163
|
+
***
|
|
164
|
+
|
|
147
165
|
### health()
|
|
148
166
|
|
|
149
167
|
> **health**(): `Promise`\<`IHealthInfo`\>
|
|
@@ -164,7 +182,7 @@ The service health.
|
|
|
164
182
|
|
|
165
183
|
### setComponentHealth()
|
|
166
184
|
|
|
167
|
-
> **setComponentHealth**(`name`, `status`, `details?`): `Promise`\<`void`\>
|
|
185
|
+
> **setComponentHealth**(`name`, `status`, `details?`, `tenantId?`): `Promise`\<`void`\>
|
|
168
186
|
|
|
169
187
|
Set the status of a component.
|
|
170
188
|
|
|
@@ -188,6 +206,12 @@ The status of the component.
|
|
|
188
206
|
|
|
189
207
|
The details for the status.
|
|
190
208
|
|
|
209
|
+
##### tenantId?
|
|
210
|
+
|
|
211
|
+
`string`
|
|
212
|
+
|
|
213
|
+
The tenant id, optional if the health status is not tenant specific.
|
|
214
|
+
|
|
191
215
|
#### Returns
|
|
192
216
|
|
|
193
217
|
`Promise`\<`void`\>
|
|
@@ -202,7 +226,7 @@ Nothing.
|
|
|
202
226
|
|
|
203
227
|
### removeComponentHealth()
|
|
204
228
|
|
|
205
|
-
> **removeComponentHealth**(`name`): `Promise`\<`void`\>
|
|
229
|
+
> **removeComponentHealth**(`name`, `tenantId?`): `Promise`\<`void`\>
|
|
206
230
|
|
|
207
231
|
Remove the status of a component.
|
|
208
232
|
|
|
@@ -214,6 +238,12 @@ Remove the status of a component.
|
|
|
214
238
|
|
|
215
239
|
The component name.
|
|
216
240
|
|
|
241
|
+
##### tenantId?
|
|
242
|
+
|
|
243
|
+
`string`
|
|
244
|
+
|
|
245
|
+
The tenant id, optional if the health status is not tenant specific.
|
|
246
|
+
|
|
217
247
|
#### Returns
|
|
218
248
|
|
|
219
249
|
`Promise`\<`void`\>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Function: serverLivez()
|
|
2
|
+
|
|
3
|
+
> **serverLivez**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`IServerLivezResponse`\>
|
|
4
|
+
|
|
5
|
+
Get the livez for the server.
|
|
6
|
+
|
|
7
|
+
## Parameters
|
|
8
|
+
|
|
9
|
+
### httpRequestContext
|
|
10
|
+
|
|
11
|
+
`IHttpRequestContext`
|
|
12
|
+
|
|
13
|
+
The request context for the API.
|
|
14
|
+
|
|
15
|
+
### componentName
|
|
16
|
+
|
|
17
|
+
`string`
|
|
18
|
+
|
|
19
|
+
The name of the component to use in the routes.
|
|
20
|
+
|
|
21
|
+
### request
|
|
22
|
+
|
|
23
|
+
`INoContentRequest`
|
|
24
|
+
|
|
25
|
+
The request.
|
|
26
|
+
|
|
27
|
+
## Returns
|
|
28
|
+
|
|
29
|
+
`Promise`\<`IServerLivezResponse`\>
|
|
30
|
+
|
|
31
|
+
The response object with additional http response properties.
|
package/docs/reference/index.md
CHANGED
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
## Classes
|
|
4
4
|
|
|
5
|
+
- [HostingService](classes/HostingService.md)
|
|
5
6
|
- [InformationService](classes/InformationService.md)
|
|
6
7
|
|
|
7
8
|
## Interfaces
|
|
8
9
|
|
|
10
|
+
- [IHostingServiceConfig](interfaces/IHostingServiceConfig.md)
|
|
11
|
+
- [IHostingServiceConstructorOptions](interfaces/IHostingServiceConstructorOptions.md)
|
|
9
12
|
- [IInformationServiceConfig](interfaces/IInformationServiceConfig.md)
|
|
10
13
|
- [IInformationServiceConstructorOptions](interfaces/IInformationServiceConstructorOptions.md)
|
|
11
14
|
|
|
@@ -19,6 +22,7 @@
|
|
|
19
22
|
- [generateRestRoutesInformation](functions/generateRestRoutesInformation.md)
|
|
20
23
|
- [serverRoot](functions/serverRoot.md)
|
|
21
24
|
- [serverInfo](functions/serverInfo.md)
|
|
25
|
+
- [serverLivez](functions/serverLivez.md)
|
|
22
26
|
- [serverHealth](functions/serverHealth.md)
|
|
23
27
|
- [serverFavIcon](functions/serverFavIcon.md)
|
|
24
28
|
- [serverSpec](functions/serverSpec.md)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Interface: IHostingServiceConfig
|
|
2
|
+
|
|
3
|
+
Configuration for the hosting service.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### localOrigin
|
|
8
|
+
|
|
9
|
+
> **localOrigin**: `string`
|
|
10
|
+
|
|
11
|
+
The local origin, must be provided as a fallback e.g. http://localhost:1234.
|
|
12
|
+
|
|
13
|
+
***
|
|
14
|
+
|
|
15
|
+
### publicOrigin?
|
|
16
|
+
|
|
17
|
+
> `optional` **publicOrigin**: `string`
|
|
18
|
+
|
|
19
|
+
The APIs public base URL e.g. "https://api.example.com:1234".
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Interface: IHostingServiceConstructorOptions
|
|
2
|
+
|
|
3
|
+
Options for the IHostingService constructor.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### tenantAdminComponentType?
|
|
8
|
+
|
|
9
|
+
> `optional` **tenantAdminComponentType**: `string`
|
|
10
|
+
|
|
11
|
+
The tenant admin component type.
|
|
12
|
+
|
|
13
|
+
***
|
|
14
|
+
|
|
15
|
+
### config
|
|
16
|
+
|
|
17
|
+
> **config**: [`IHostingServiceConfig`](IHostingServiceConfig.md)
|
|
18
|
+
|
|
19
|
+
The configuration for the service.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/api-service",
|
|
3
|
-
"version": "0.0.3-next.
|
|
4
|
-
"description": "Information
|
|
3
|
+
"version": "0.0.3-next.21",
|
|
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,8 @@
|
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@twin.org/api-models": "0.0.3-next.
|
|
17
|
+
"@twin.org/api-models": "0.0.3-next.21",
|
|
18
|
+
"@twin.org/context": "next",
|
|
18
19
|
"@twin.org/core": "next",
|
|
19
20
|
"@twin.org/nameof": "next",
|
|
20
21
|
"@twin.org/web": "next"
|