@twin.org/api-server-fastify 0.0.3-next.4 → 0.0.3-next.40

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/docs/examples.md CHANGED
@@ -1 +1,37 @@
1
- # @twin.org/api-server-fastify - Examples
1
+ # Server Fastify Examples
2
+
3
+ Use these snippets to build and run the Fastify server with explicit lifecycle control in scripts and integration tests.
4
+
5
+ ## FastifyWebServer
6
+
7
+ ```typescript
8
+ import { FastifyWebServer } from '@twin.org/api-server-fastify';
9
+
10
+ const webServer = new FastifyWebServer();
11
+
12
+ await webServer.build(undefined, undefined, undefined, undefined, {
13
+ port: 8080,
14
+ host: '0.0.0.0'
15
+ });
16
+
17
+ await webServer.start();
18
+ const instance = webServer.getInstance();
19
+
20
+ console.log(instance.server.address() !== null); // true
21
+
22
+ await webServer.stop();
23
+ ```
24
+
25
+ ```typescript
26
+ import { FastifyWebServer } from '@twin.org/api-server-fastify';
27
+
28
+ const webServer = new FastifyWebServer();
29
+
30
+ await webServer.build(undefined, undefined, undefined, undefined, {
31
+ port: 3000,
32
+ host: '127.0.0.1'
33
+ });
34
+
35
+ await webServer.start();
36
+ await webServer.stop();
37
+ ```
@@ -28,7 +28,7 @@ The options for the server.
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,25 @@ Runtime name for the class.
36
36
 
37
37
  ## Methods
38
38
 
39
- ### getInstance()
39
+ ### className() {#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
+ `IWebServer.className`
54
+
55
+ ***
56
+
57
+ ### getInstance() {#getinstance}
40
58
 
41
59
  > **getInstance**(): `FastifyInstance`
42
60
 
@@ -54,7 +72,7 @@ The web server instance.
54
72
 
55
73
  ***
56
74
 
57
- ### build()
75
+ ### build() {#build}
58
76
 
59
77
  > **build**(`restRouteProcessors?`, `restRoutes?`, `socketRouteProcessors?`, `socketRoutes?`, `options?`): `Promise`\<`void`\>
60
78
 
@@ -104,7 +122,7 @@ Nothing.
104
122
 
105
123
  ***
106
124
 
107
- ### start()
125
+ ### start() {#start}
108
126
 
109
127
  > **start**(): `Promise`\<`void`\>
110
128
 
@@ -122,7 +140,7 @@ Nothing.
122
140
 
123
141
  ***
124
142
 
125
- ### stop()
143
+ ### stop() {#stop}
126
144
 
127
145
  > **stop**(): `Promise`\<`void`\>
128
146
 
@@ -137,3 +155,21 @@ Nothing.
137
155
  #### Implementation of
138
156
 
139
157
  `IWebServer.stop`
158
+
159
+ ***
160
+
161
+ ### health() {#health}
162
+
163
+ > **health**(): `Promise`\<`IHealth`[]\>
164
+
165
+ Perform a health check on the server by fetching its own root endpoint.
166
+
167
+ #### Returns
168
+
169
+ `Promise`\<`IHealth`[]\>
170
+
171
+ The health status of the server.
172
+
173
+ #### Implementation of
174
+
175
+ `IWebServer.health`
@@ -4,24 +4,24 @@ The configuration for the Fastify web server.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### web?
7
+ ### web? {#web}
8
8
 
9
- > `optional` **web**: `Partial`\<`FastifyServerOptions`\>
9
+ > `optional` **web?**: `Partial`\<`FastifyServerOptions`\>
10
10
 
11
11
  The web server options.
12
12
 
13
13
  ***
14
14
 
15
- ### socket?
15
+ ### socket? {#socket}
16
16
 
17
- > `optional` **socket**: `Partial`\<`ServerOptions`\>
17
+ > `optional` **socket?**: `Partial`\<`ServerOptions`\>
18
18
 
19
19
  The socket server options.
20
20
 
21
21
  ***
22
22
 
23
- ### includeErrorStack?
23
+ ### includeErrorStack? {#includeerrorstack}
24
24
 
25
- > `optional` **includeErrorStack**: `boolean`
25
+ > `optional` **includeErrorStack?**: `boolean`
26
26
 
27
27
  Include the stack with errors.
@@ -4,24 +4,32 @@ The options for the Fastify web server constructor.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### loggingComponentType?
7
+ ### loggingComponentType? {#loggingcomponenttype}
8
8
 
9
- > `optional` **loggingComponentType**: `string`
9
+ > `optional` **loggingComponentType?**: `string`
10
10
 
11
11
  The type of the logging component to use, if undefined, no logging will happen.
12
12
 
13
13
  ***
14
14
 
15
- ### config?
15
+ ### hostingComponentType? {#hostingcomponenttype}
16
16
 
17
- > `optional` **config**: [`IFastifyWebServerConfig`](IFastifyWebServerConfig.md)
17
+ > `optional` **hostingComponentType?**: `string`
18
+
19
+ The type of the hosting component to use.
20
+
21
+ ***
22
+
23
+ ### config? {#config}
24
+
25
+ > `optional` **config?**: [`IFastifyWebServerConfig`](IFastifyWebServerConfig.md)
18
26
 
19
27
  Additional configuration for the server.
20
28
 
21
29
  ***
22
30
 
23
- ### mimeTypeProcessors?
31
+ ### mimeTypeProcessors? {#mimetypeprocessors}
24
32
 
25
- > `optional` **mimeTypeProcessors**: `IMimeTypeProcessor`[]
33
+ > `optional` **mimeTypeProcessors?**: `IMimeTypeProcessor`[]
26
34
 
27
35
  Additional MIME type processors.
@@ -1,2 +1,3 @@
1
- ^>=5.x.x$
2
- ^socket.io$
1
+ # Fastify plugin options in fastifySocketIo.ts — not locale keys
2
+ >=5\.x\.x
3
+ socket\.io
package/locales/en.json CHANGED
@@ -17,5 +17,12 @@
17
17
  "restRouteAdded": "Added REST route \"{route}\" \"{method}\"",
18
18
  "socketRouteAdded": "Added socket route: handshake path \"{handshakePath}\", namespace \"{namespace}\", event name \"{eventName}\""
19
19
  }
20
+ },
21
+ "health": {
22
+ "fastifyWebServer": {
23
+ "description": "Checks if the Web Server is reachable",
24
+ "reachable": "The Web Server is reachable",
25
+ "unreachable": "The Web Server is unreachable"
26
+ }
20
27
  }
21
28
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@twin.org/api-server-fastify",
3
- "version": "0.0.3-next.4",
4
- "description": "Use Fastify as the core web server for APIs",
3
+ "version": "0.0.3-next.40",
4
+ "description": "Fastify web server integration for exposing API routes with consistent runtime behaviour.",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "git+https://github.com/twinfoundation/api.git",
7
+ "url": "git+https://github.com/iotaledger/twin-api.git",
8
8
  "directory": "packages/api-server-fastify"
9
9
  },
10
10
  "author": "martyn.janes@iota.org",
@@ -14,18 +14,18 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@fastify/compress": "8.3.0",
18
- "@fastify/cors": "11.1.0",
19
- "@twin.org/api-core": "0.0.3-next.4",
20
- "@twin.org/api-models": "0.0.3-next.4",
21
- "@twin.org/api-processors": "0.0.3-next.4",
17
+ "@fastify/compress": "8.3.1",
18
+ "@fastify/cors": "11.2.0",
19
+ "@twin.org/api-core": "0.0.3-next.40",
20
+ "@twin.org/api-models": "0.0.3-next.40",
21
+ "@twin.org/api-processors": "0.0.3-next.40",
22
22
  "@twin.org/context": "next",
23
23
  "@twin.org/core": "next",
24
24
  "@twin.org/logging-models": "next",
25
25
  "@twin.org/nameof": "next",
26
26
  "@twin.org/web": "next",
27
- "fastify": "5.6.2",
28
- "socket.io": "4.8.1"
27
+ "fastify": "5.8.5",
28
+ "socket.io": "4.8.3"
29
29
  },
30
30
  "main": "./dist/es/index.js",
31
31
  "types": "./dist/types/index.d.ts",
@@ -51,7 +51,7 @@
51
51
  "api"
52
52
  ],
53
53
  "bugs": {
54
- "url": "git+https://github.com/twinfoundation/api/issues"
54
+ "url": "git+https://github.com/iotaledger/twin-api/issues"
55
55
  },
56
56
  "homepage": "https://twindev.org"
57
57
  }