@twin.org/api-server-fastify 0.0.2-next.11 → 0.0.2-next.12

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.
@@ -27,6 +27,10 @@ const fastifySocketIO = fp(async (fastify, opts) => {
27
27
  * Implementation of the web server using Fastify.
28
28
  */
29
29
  class FastifyWebServer {
30
+ /**
31
+ * Runtime name for the class.
32
+ */
33
+ static CLASS_NAME = "FastifyWebServer";
30
34
  /**
31
35
  * Default port for running the server.
32
36
  * @internal
@@ -37,10 +41,6 @@ class FastifyWebServer {
37
41
  * @internal
38
42
  */
39
43
  static _DEFAULT_HOST = "localhost";
40
- /**
41
- * Runtime name for the class.
42
- */
43
- CLASS_NAME = "FastifyWebServer";
44
44
  /**
45
45
  * The logging component type.
46
46
  * @internal
@@ -126,15 +126,15 @@ class FastifyWebServer {
126
126
  */
127
127
  async build(restRouteProcessors, restRoutes, socketRouteProcessors, socketRoutes, options) {
128
128
  if (core.Is.arrayValue(restRoutes) && !core.Is.arrayValue(restRouteProcessors)) {
129
- throw new core.GeneralError(this.CLASS_NAME, "noRestProcessors");
129
+ throw new core.GeneralError(FastifyWebServer.CLASS_NAME, "noRestProcessors");
130
130
  }
131
131
  if (core.Is.arrayValue(socketRoutes) && !core.Is.arrayValue(socketRouteProcessors)) {
132
- throw new core.GeneralError(this.CLASS_NAME, "noSocketProcessors");
132
+ throw new core.GeneralError(FastifyWebServer.CLASS_NAME, "noSocketProcessors");
133
133
  }
134
134
  await this._logging?.log({
135
135
  level: "info",
136
136
  ts: Date.now(),
137
- source: this.CLASS_NAME,
137
+ source: FastifyWebServer.CLASS_NAME,
138
138
  message: `${"fastifyWebServer"}.building`
139
139
  });
140
140
  this._options = options;
@@ -165,7 +165,7 @@ class FastifyWebServer {
165
165
  let err;
166
166
  if (core.Is.number(error.code)) {
167
167
  err = {
168
- source: this.CLASS_NAME,
168
+ source: FastifyWebServer.CLASS_NAME,
169
169
  name: error.name,
170
170
  message: `${error.code}: ${error.message}`
171
171
  };
@@ -179,7 +179,7 @@ class FastifyWebServer {
179
179
  await this._logging?.log({
180
180
  level: "error",
181
181
  ts: Date.now(),
182
- source: this.CLASS_NAME,
182
+ source: FastifyWebServer.CLASS_NAME,
183
183
  message: `${"fastifyWebServer"}.badRequest`,
184
184
  error: err
185
185
  });
@@ -200,7 +200,7 @@ class FastifyWebServer {
200
200
  await this._logging?.log({
201
201
  level: "info",
202
202
  ts: Date.now(),
203
- source: this.CLASS_NAME,
203
+ source: FastifyWebServer.CLASS_NAME,
204
204
  message: `${"fastifyWebServer"}.starting`,
205
205
  data: {
206
206
  host,
@@ -215,7 +215,7 @@ class FastifyWebServer {
215
215
  await this._logging?.log({
216
216
  level: "info",
217
217
  ts: Date.now(),
218
- source: this.CLASS_NAME,
218
+ source: FastifyWebServer.CLASS_NAME,
219
219
  message: `${"fastifyWebServer"}.started`,
220
220
  data: {
221
221
  addresses: addresses
@@ -229,7 +229,7 @@ class FastifyWebServer {
229
229
  await this._logging?.log({
230
230
  level: "error",
231
231
  ts: Date.now(),
232
- source: this.CLASS_NAME,
232
+ source: FastifyWebServer.CLASS_NAME,
233
233
  message: `${"fastifyWebServer"}.startFailed`,
234
234
  error: core.BaseError.fromError(err)
235
235
  });
@@ -247,7 +247,7 @@ class FastifyWebServer {
247
247
  await this._logging?.log({
248
248
  level: "info",
249
249
  ts: Date.now(),
250
- source: this.CLASS_NAME,
250
+ source: FastifyWebServer.CLASS_NAME,
251
251
  message: `${"fastifyWebServer"}.stopped`
252
252
  });
253
253
  }
@@ -268,7 +268,7 @@ class FastifyWebServer {
268
268
  await this._logging?.log({
269
269
  level: "info",
270
270
  ts: Date.now(),
271
- source: this.CLASS_NAME,
271
+ source: FastifyWebServer.CLASS_NAME,
272
272
  message: `${"fastifyWebServer"}.restRouteAdded`,
273
273
  data: { route: path, method: restRoute.method }
274
274
  });
@@ -295,7 +295,7 @@ class FastifyWebServer {
295
295
  await this._logging?.log({
296
296
  level: "info",
297
297
  ts: Date.now(),
298
- source: this.CLASS_NAME,
298
+ source: FastifyWebServer.CLASS_NAME,
299
299
  message: `${"fastifyWebServer"}.socketRouteAdded`,
300
300
  data: {
301
301
  handshakePath: this._socketConfig.path,
@@ -494,7 +494,7 @@ class FastifyWebServer {
494
494
  this._logging?.log({
495
495
  level: "error",
496
496
  ts: Date.now(),
497
- source: this.CLASS_NAME,
497
+ source: FastifyWebServer.CLASS_NAME,
498
498
  message: `${"fastifyWebServer"}.postProcessorError`,
499
499
  error: core.BaseError.fromError(err),
500
500
  data: {
@@ -25,6 +25,10 @@ const fastifySocketIO = fp(async (fastify, opts) => {
25
25
  * Implementation of the web server using Fastify.
26
26
  */
27
27
  class FastifyWebServer {
28
+ /**
29
+ * Runtime name for the class.
30
+ */
31
+ static CLASS_NAME = "FastifyWebServer";
28
32
  /**
29
33
  * Default port for running the server.
30
34
  * @internal
@@ -35,10 +39,6 @@ class FastifyWebServer {
35
39
  * @internal
36
40
  */
37
41
  static _DEFAULT_HOST = "localhost";
38
- /**
39
- * Runtime name for the class.
40
- */
41
- CLASS_NAME = "FastifyWebServer";
42
42
  /**
43
43
  * The logging component type.
44
44
  * @internal
@@ -124,15 +124,15 @@ class FastifyWebServer {
124
124
  */
125
125
  async build(restRouteProcessors, restRoutes, socketRouteProcessors, socketRoutes, options) {
126
126
  if (Is.arrayValue(restRoutes) && !Is.arrayValue(restRouteProcessors)) {
127
- throw new GeneralError(this.CLASS_NAME, "noRestProcessors");
127
+ throw new GeneralError(FastifyWebServer.CLASS_NAME, "noRestProcessors");
128
128
  }
129
129
  if (Is.arrayValue(socketRoutes) && !Is.arrayValue(socketRouteProcessors)) {
130
- throw new GeneralError(this.CLASS_NAME, "noSocketProcessors");
130
+ throw new GeneralError(FastifyWebServer.CLASS_NAME, "noSocketProcessors");
131
131
  }
132
132
  await this._logging?.log({
133
133
  level: "info",
134
134
  ts: Date.now(),
135
- source: this.CLASS_NAME,
135
+ source: FastifyWebServer.CLASS_NAME,
136
136
  message: `${"fastifyWebServer"}.building`
137
137
  });
138
138
  this._options = options;
@@ -163,7 +163,7 @@ class FastifyWebServer {
163
163
  let err;
164
164
  if (Is.number(error.code)) {
165
165
  err = {
166
- source: this.CLASS_NAME,
166
+ source: FastifyWebServer.CLASS_NAME,
167
167
  name: error.name,
168
168
  message: `${error.code}: ${error.message}`
169
169
  };
@@ -177,7 +177,7 @@ class FastifyWebServer {
177
177
  await this._logging?.log({
178
178
  level: "error",
179
179
  ts: Date.now(),
180
- source: this.CLASS_NAME,
180
+ source: FastifyWebServer.CLASS_NAME,
181
181
  message: `${"fastifyWebServer"}.badRequest`,
182
182
  error: err
183
183
  });
@@ -198,7 +198,7 @@ class FastifyWebServer {
198
198
  await this._logging?.log({
199
199
  level: "info",
200
200
  ts: Date.now(),
201
- source: this.CLASS_NAME,
201
+ source: FastifyWebServer.CLASS_NAME,
202
202
  message: `${"fastifyWebServer"}.starting`,
203
203
  data: {
204
204
  host,
@@ -213,7 +213,7 @@ class FastifyWebServer {
213
213
  await this._logging?.log({
214
214
  level: "info",
215
215
  ts: Date.now(),
216
- source: this.CLASS_NAME,
216
+ source: FastifyWebServer.CLASS_NAME,
217
217
  message: `${"fastifyWebServer"}.started`,
218
218
  data: {
219
219
  addresses: addresses
@@ -227,7 +227,7 @@ class FastifyWebServer {
227
227
  await this._logging?.log({
228
228
  level: "error",
229
229
  ts: Date.now(),
230
- source: this.CLASS_NAME,
230
+ source: FastifyWebServer.CLASS_NAME,
231
231
  message: `${"fastifyWebServer"}.startFailed`,
232
232
  error: BaseError.fromError(err)
233
233
  });
@@ -245,7 +245,7 @@ class FastifyWebServer {
245
245
  await this._logging?.log({
246
246
  level: "info",
247
247
  ts: Date.now(),
248
- source: this.CLASS_NAME,
248
+ source: FastifyWebServer.CLASS_NAME,
249
249
  message: `${"fastifyWebServer"}.stopped`
250
250
  });
251
251
  }
@@ -266,7 +266,7 @@ class FastifyWebServer {
266
266
  await this._logging?.log({
267
267
  level: "info",
268
268
  ts: Date.now(),
269
- source: this.CLASS_NAME,
269
+ source: FastifyWebServer.CLASS_NAME,
270
270
  message: `${"fastifyWebServer"}.restRouteAdded`,
271
271
  data: { route: path, method: restRoute.method }
272
272
  });
@@ -293,7 +293,7 @@ class FastifyWebServer {
293
293
  await this._logging?.log({
294
294
  level: "info",
295
295
  ts: Date.now(),
296
- source: this.CLASS_NAME,
296
+ source: FastifyWebServer.CLASS_NAME,
297
297
  message: `${"fastifyWebServer"}.socketRouteAdded`,
298
298
  data: {
299
299
  handshakePath: this._socketConfig.path,
@@ -492,7 +492,7 @@ class FastifyWebServer {
492
492
  this._logging?.log({
493
493
  level: "error",
494
494
  ts: Date.now(),
495
- source: this.CLASS_NAME,
495
+ source: FastifyWebServer.CLASS_NAME,
496
496
  message: `${"fastifyWebServer"}.postProcessorError`,
497
497
  error: BaseError.fromError(err),
498
498
  data: {
@@ -8,7 +8,7 @@ export declare class FastifyWebServer implements IWebServer<FastifyInstance> {
8
8
  /**
9
9
  * Runtime name for the class.
10
10
  */
11
- readonly CLASS_NAME: string;
11
+ static readonly CLASS_NAME: string;
12
12
  /**
13
13
  * Create a new instance of FastifyWebServer.
14
14
  * @param options The options for the server.
package/docs/changelog.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @twin.org/api-server-fastify - Changelog
2
2
 
3
+ ## [0.0.2-next.12](https://github.com/twinfoundation/api/compare/api-server-fastify-v0.0.2-next.11...api-server-fastify-v0.0.2-next.12) (2025-10-09)
4
+
5
+
6
+ ### Features
7
+
8
+ * add validate-locales ([cdba610](https://github.com/twinfoundation/api/commit/cdba610a0acb5022d2e3ce729732e6646a297e5e))
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.11 to 0.0.2-next.12
16
+ * @twin.org/api-models bumped from 0.0.2-next.11 to 0.0.2-next.12
17
+ * @twin.org/api-processors bumped from 0.0.2-next.11 to 0.0.2-next.12
18
+
3
19
  ## [0.0.2-next.11](https://github.com/twinfoundation/api/compare/api-server-fastify-v0.0.2-next.10...api-server-fastify-v0.0.2-next.11) (2025-09-29)
4
20
 
5
21
 
@@ -30,7 +30,7 @@ The options for the server.
30
30
 
31
31
  ### CLASS\_NAME
32
32
 
33
- > `readonly` **CLASS\_NAME**: `string`
33
+ > `readonly` `static` **CLASS\_NAME**: `string`
34
34
 
35
35
  Runtime name for the class.
36
36
 
@@ -0,0 +1,2 @@
1
+ ^>=5.x.x$
2
+ ^socket.io$
package/locales/en.json CHANGED
@@ -1,15 +1,21 @@
1
1
  {
2
- "fastifyWebServer": {
3
- "building": "Building Web Server",
4
- "starting": "Starting Web Server at address \"{host}\" on port \"{port}\"",
5
- "startFailed": "The Web Server failed to start",
6
- "started": "The Web Server started on {addresses}",
7
- "stopped": "The Web Server was stopped",
8
- "badRequest": "The web server could not handle the request",
9
- "restRouteAdded": "Added REST route \"{route}\" \"{method}\"",
10
- "socketRouteAdded": "Added socket route: handshake path \"{handshakePath}\", namespace \"{namespace}\", event name \"{eventName}\"",
11
- "noRestProcessors": "You must configure at least one REST processor",
12
- "noSocketProcessors": "You must configure at least one socket processor",
13
- "postProcessorError": "There was a failure after in a post processor for route \"{route}\""
2
+ "error": {
3
+ "fastifyWebServer": {
4
+ "startFailed": "The Web Server failed to start",
5
+ "badRequest": "The web server could not handle the request",
6
+ "noRestProcessors": "You must configure at least one REST processor",
7
+ "noSocketProcessors": "You must configure at least one socket processor",
8
+ "postProcessorError": "There was a failure after in a post processor for route \"{route}\""
9
+ }
10
+ },
11
+ "info": {
12
+ "fastifyWebServer": {
13
+ "building": "Building Web Server",
14
+ "starting": "Starting Web Server at address \"{host}\" on port \"{port}\"",
15
+ "started": "The Web Server started on {addresses}",
16
+ "stopped": "The Web Server was stopped",
17
+ "restRouteAdded": "Added REST route \"{route}\" \"{method}\"",
18
+ "socketRouteAdded": "Added socket route: handshake path \"{handshakePath}\", namespace \"{namespace}\", event name \"{eventName}\""
19
+ }
14
20
  }
15
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/api-server-fastify",
3
- "version": "0.0.2-next.11",
3
+ "version": "0.0.2-next.12",
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.11",
20
- "@twin.org/api-models": "0.0.2-next.11",
21
- "@twin.org/api-processors": "0.0.2-next.11",
19
+ "@twin.org/api-core": "0.0.2-next.12",
20
+ "@twin.org/api-models": "0.0.2-next.12",
21
+ "@twin.org/api-processors": "0.0.2-next.12",
22
22
  "@twin.org/core": "next",
23
23
  "@twin.org/logging-models": "next",
24
24
  "@twin.org/nameof": "next",
@@ -42,5 +42,17 @@
42
42
  "dist/types",
43
43
  "locales",
44
44
  "docs"
45
- ]
45
+ ],
46
+ "keywords": [
47
+ "twin",
48
+ "trade",
49
+ "iota",
50
+ "framework",
51
+ "blockchain",
52
+ "api"
53
+ ],
54
+ "bugs": {
55
+ "url": "git+https://github.com/twinfoundation/api/issues"
56
+ },
57
+ "homepage": "https://twindev.org"
46
58
  }