@twin.org/api-server-fastify 0.0.2-next.6 → 0.0.2-next.8

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.
@@ -55,7 +55,7 @@ class FastifyWebServer {
55
55
  * The logging component.
56
56
  * @internal
57
57
  */
58
- _loggingComponent;
58
+ _logging;
59
59
  /**
60
60
  * The options for the server.
61
61
  * @internal
@@ -92,12 +92,14 @@ class FastifyWebServer {
92
92
  */
93
93
  constructor(options) {
94
94
  this._loggingComponentType = options?.loggingComponentType;
95
- this._loggingComponent = core.Is.stringValue(options?.loggingComponentType)
96
- ? core.ComponentFactory.get(options.loggingComponentType)
97
- : undefined;
95
+ this._logging = core.ComponentFactory.getIfExists(options?.loggingComponentType ?? "logging");
98
96
  this._fastify = Fastify({
99
- maxParamLength: 2000,
97
+ routerOptions: {
98
+ maxParamLength: 2000
99
+ },
100
100
  ...options?.config?.web
101
+ // Need this cast for now as maxParamLength has moved in to routerOptions
102
+ // but the TS defs has not been updated yet
101
103
  });
102
104
  this._socketConfig = {
103
105
  path: "/socket",
@@ -134,7 +136,7 @@ class FastifyWebServer {
134
136
  if (core.Is.arrayValue(socketRoutes) && !core.Is.arrayValue(socketRouteProcessors)) {
135
137
  throw new core.GeneralError(this.CLASS_NAME, "noSocketProcessors");
136
138
  }
137
- await this._loggingComponent?.log({
139
+ await this._logging?.log({
138
140
  level: "info",
139
141
  ts: Date.now(),
140
142
  source: this.CLASS_NAME,
@@ -179,7 +181,7 @@ class FastifyWebServer {
179
181
  err = errorAndCode.error;
180
182
  httpStatusCode = errorAndCode.httpStatusCode;
181
183
  }
182
- await this._loggingComponent?.log({
184
+ await this._logging?.log({
183
185
  level: "error",
184
186
  ts: Date.now(),
185
187
  source: this.CLASS_NAME,
@@ -200,7 +202,7 @@ class FastifyWebServer {
200
202
  async start() {
201
203
  const host = this._options?.host ?? FastifyWebServer._DEFAULT_HOST;
202
204
  const port = this._options?.port ?? FastifyWebServer._DEFAULT_PORT;
203
- await this._loggingComponent?.log({
205
+ await this._logging?.log({
204
206
  level: "info",
205
207
  ts: Date.now(),
206
208
  source: this.CLASS_NAME,
@@ -215,7 +217,7 @@ class FastifyWebServer {
215
217
  await this._fastify.listen({ port, host });
216
218
  const addresses = this._fastify.addresses();
217
219
  const protocol = core.Is.object(this._fastify.initialConfig.https) ? "https://" : "http://";
218
- await this._loggingComponent?.log({
220
+ await this._logging?.log({
219
221
  level: "info",
220
222
  ts: Date.now(),
221
223
  source: this.CLASS_NAME,
@@ -229,7 +231,7 @@ class FastifyWebServer {
229
231
  this._started = true;
230
232
  }
231
233
  catch (err) {
232
- await this._loggingComponent?.log({
234
+ await this._logging?.log({
233
235
  level: "error",
234
236
  ts: Date.now(),
235
237
  source: this.CLASS_NAME,
@@ -247,7 +249,7 @@ class FastifyWebServer {
247
249
  if (this._started) {
248
250
  this._started = false;
249
251
  await this._fastify.close();
250
- await this._loggingComponent?.log({
252
+ await this._logging?.log({
251
253
  level: "info",
252
254
  ts: Date.now(),
253
255
  source: this.CLASS_NAME,
@@ -268,7 +270,7 @@ class FastifyWebServer {
268
270
  if (!path.startsWith("/")) {
269
271
  path = `/${path}`;
270
272
  }
271
- await this._loggingComponent?.log({
273
+ await this._logging?.log({
272
274
  level: "info",
273
275
  ts: Date.now(),
274
276
  source: this.CLASS_NAME,
@@ -295,7 +297,7 @@ class FastifyWebServer {
295
297
  const pathParts = path.split("/");
296
298
  const namespace = `/${pathParts[0]}`;
297
299
  const topic = pathParts.slice(1).join("/");
298
- await this._loggingComponent?.log({
300
+ await this._logging?.log({
299
301
  level: "info",
300
302
  ts: Date.now(),
301
303
  source: this.CLASS_NAME,
@@ -465,7 +467,7 @@ class FastifyWebServer {
465
467
  }
466
468
  }
467
469
  catch (err) {
468
- this._loggingComponent?.log({
470
+ this._logging?.log({
469
471
  level: "error",
470
472
  ts: Date.now(),
471
473
  source: this.CLASS_NAME,
@@ -53,7 +53,7 @@ class FastifyWebServer {
53
53
  * The logging component.
54
54
  * @internal
55
55
  */
56
- _loggingComponent;
56
+ _logging;
57
57
  /**
58
58
  * The options for the server.
59
59
  * @internal
@@ -90,12 +90,14 @@ class FastifyWebServer {
90
90
  */
91
91
  constructor(options) {
92
92
  this._loggingComponentType = options?.loggingComponentType;
93
- this._loggingComponent = Is.stringValue(options?.loggingComponentType)
94
- ? ComponentFactory.get(options.loggingComponentType)
95
- : undefined;
93
+ this._logging = ComponentFactory.getIfExists(options?.loggingComponentType ?? "logging");
96
94
  this._fastify = Fastify({
97
- maxParamLength: 2000,
95
+ routerOptions: {
96
+ maxParamLength: 2000
97
+ },
98
98
  ...options?.config?.web
99
+ // Need this cast for now as maxParamLength has moved in to routerOptions
100
+ // but the TS defs has not been updated yet
99
101
  });
100
102
  this._socketConfig = {
101
103
  path: "/socket",
@@ -132,7 +134,7 @@ class FastifyWebServer {
132
134
  if (Is.arrayValue(socketRoutes) && !Is.arrayValue(socketRouteProcessors)) {
133
135
  throw new GeneralError(this.CLASS_NAME, "noSocketProcessors");
134
136
  }
135
- await this._loggingComponent?.log({
137
+ await this._logging?.log({
136
138
  level: "info",
137
139
  ts: Date.now(),
138
140
  source: this.CLASS_NAME,
@@ -177,7 +179,7 @@ class FastifyWebServer {
177
179
  err = errorAndCode.error;
178
180
  httpStatusCode = errorAndCode.httpStatusCode;
179
181
  }
180
- await this._loggingComponent?.log({
182
+ await this._logging?.log({
181
183
  level: "error",
182
184
  ts: Date.now(),
183
185
  source: this.CLASS_NAME,
@@ -198,7 +200,7 @@ class FastifyWebServer {
198
200
  async start() {
199
201
  const host = this._options?.host ?? FastifyWebServer._DEFAULT_HOST;
200
202
  const port = this._options?.port ?? FastifyWebServer._DEFAULT_PORT;
201
- await this._loggingComponent?.log({
203
+ await this._logging?.log({
202
204
  level: "info",
203
205
  ts: Date.now(),
204
206
  source: this.CLASS_NAME,
@@ -213,7 +215,7 @@ class FastifyWebServer {
213
215
  await this._fastify.listen({ port, host });
214
216
  const addresses = this._fastify.addresses();
215
217
  const protocol = Is.object(this._fastify.initialConfig.https) ? "https://" : "http://";
216
- await this._loggingComponent?.log({
218
+ await this._logging?.log({
217
219
  level: "info",
218
220
  ts: Date.now(),
219
221
  source: this.CLASS_NAME,
@@ -227,7 +229,7 @@ class FastifyWebServer {
227
229
  this._started = true;
228
230
  }
229
231
  catch (err) {
230
- await this._loggingComponent?.log({
232
+ await this._logging?.log({
231
233
  level: "error",
232
234
  ts: Date.now(),
233
235
  source: this.CLASS_NAME,
@@ -245,7 +247,7 @@ class FastifyWebServer {
245
247
  if (this._started) {
246
248
  this._started = false;
247
249
  await this._fastify.close();
248
- await this._loggingComponent?.log({
250
+ await this._logging?.log({
249
251
  level: "info",
250
252
  ts: Date.now(),
251
253
  source: this.CLASS_NAME,
@@ -266,7 +268,7 @@ class FastifyWebServer {
266
268
  if (!path.startsWith("/")) {
267
269
  path = `/${path}`;
268
270
  }
269
- await this._loggingComponent?.log({
271
+ await this._logging?.log({
270
272
  level: "info",
271
273
  ts: Date.now(),
272
274
  source: this.CLASS_NAME,
@@ -293,7 +295,7 @@ class FastifyWebServer {
293
295
  const pathParts = path.split("/");
294
296
  const namespace = `/${pathParts[0]}`;
295
297
  const topic = pathParts.slice(1).join("/");
296
- await this._loggingComponent?.log({
298
+ await this._logging?.log({
297
299
  level: "info",
298
300
  ts: Date.now(),
299
301
  source: this.CLASS_NAME,
@@ -463,7 +465,7 @@ class FastifyWebServer {
463
465
  }
464
466
  }
465
467
  catch (err) {
466
- this._loggingComponent?.log({
468
+ this._logging?.log({
467
469
  level: "error",
468
470
  ts: Date.now(),
469
471
  source: this.CLASS_NAME,
package/docs/changelog.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # @twin.org/api-server-fastify - Changelog
2
2
 
3
+ ## [0.0.2-next.8](https://github.com/twinfoundation/api/compare/api-server-fastify-v0.0.2-next.7...api-server-fastify-v0.0.2-next.8) (2025-08-21)
4
+
5
+
6
+ ### Features
7
+
8
+ * add root, favicon routes ([71da1c3](https://github.com/twinfoundation/api/commit/71da1c3a93c349588aff7084d1d8d6a29a277da8))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/api-core bumped from 0.0.2-next.7 to 0.0.2-next.8
16
+ * @twin.org/api-models bumped from 0.0.2-next.7 to 0.0.2-next.8
17
+ * @twin.org/api-processors bumped from 0.0.2-next.7 to 0.0.2-next.8
18
+
19
+ ## [0.0.2-next.7](https://github.com/twinfoundation/api/compare/api-server-fastify-v0.0.2-next.6...api-server-fastify-v0.0.2-next.7) (2025-08-20)
20
+
21
+
22
+ ### Features
23
+
24
+ * logging naming consistency ([a4a6ef2](https://github.com/twinfoundation/api/commit/a4a6ef2de5049045589eb78b177ff62e744bde9d))
25
+
26
+
27
+ ### Dependencies
28
+
29
+ * The following workspace dependencies were updated
30
+ * dependencies
31
+ * @twin.org/api-core bumped from 0.0.2-next.6 to 0.0.2-next.7
32
+ * @twin.org/api-models bumped from 0.0.2-next.6 to 0.0.2-next.7
33
+ * @twin.org/api-processors bumped from 0.0.2-next.6 to 0.0.2-next.7
34
+
3
35
  ## [0.0.2-next.6](https://github.com/twinfoundation/api/compare/api-server-fastify-v0.0.2-next.5...api-server-fastify-v0.0.2-next.6) (2025-08-19)
4
36
 
5
37
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/api-server-fastify",
3
- "version": "0.0.2-next.6",
3
+ "version": "0.0.2-next.8",
4
4
  "description": "Use Fastify as the core web server for APIs",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,9 +16,9 @@
16
16
  "dependencies": {
17
17
  "@fastify/compress": "8.1.0",
18
18
  "@fastify/cors": "11.1.0",
19
- "@twin.org/api-core": "0.0.2-next.6",
20
- "@twin.org/api-models": "0.0.2-next.6",
21
- "@twin.org/api-processors": "0.0.2-next.6",
19
+ "@twin.org/api-core": "0.0.2-next.8",
20
+ "@twin.org/api-models": "0.0.2-next.8",
21
+ "@twin.org/api-processors": "0.0.2-next.8",
22
22
  "@twin.org/core": "next",
23
23
  "@twin.org/logging-models": "next",
24
24
  "@twin.org/nameof": "next",