@twin.org/api-server-fastify 0.0.2-next.6 → 0.0.2-next.7
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/dist/cjs/index.cjs +11 -13
- package/dist/esm/index.mjs +11 -13
- package/docs/changelog.md +16 -0
- package/package.json +4 -4
package/dist/cjs/index.cjs
CHANGED
|
@@ -55,7 +55,7 @@ class FastifyWebServer {
|
|
|
55
55
|
* The logging component.
|
|
56
56
|
* @internal
|
|
57
57
|
*/
|
|
58
|
-
|
|
58
|
+
_logging;
|
|
59
59
|
/**
|
|
60
60
|
* The options for the server.
|
|
61
61
|
* @internal
|
|
@@ -92,9 +92,7 @@ class FastifyWebServer {
|
|
|
92
92
|
*/
|
|
93
93
|
constructor(options) {
|
|
94
94
|
this._loggingComponentType = options?.loggingComponentType;
|
|
95
|
-
this.
|
|
96
|
-
? core.ComponentFactory.get(options.loggingComponentType)
|
|
97
|
-
: undefined;
|
|
95
|
+
this._logging = core.ComponentFactory.getIfExists(options?.loggingComponentType ?? "logging");
|
|
98
96
|
this._fastify = Fastify({
|
|
99
97
|
maxParamLength: 2000,
|
|
100
98
|
...options?.config?.web
|
|
@@ -134,7 +132,7 @@ class FastifyWebServer {
|
|
|
134
132
|
if (core.Is.arrayValue(socketRoutes) && !core.Is.arrayValue(socketRouteProcessors)) {
|
|
135
133
|
throw new core.GeneralError(this.CLASS_NAME, "noSocketProcessors");
|
|
136
134
|
}
|
|
137
|
-
await this.
|
|
135
|
+
await this._logging?.log({
|
|
138
136
|
level: "info",
|
|
139
137
|
ts: Date.now(),
|
|
140
138
|
source: this.CLASS_NAME,
|
|
@@ -179,7 +177,7 @@ class FastifyWebServer {
|
|
|
179
177
|
err = errorAndCode.error;
|
|
180
178
|
httpStatusCode = errorAndCode.httpStatusCode;
|
|
181
179
|
}
|
|
182
|
-
await this.
|
|
180
|
+
await this._logging?.log({
|
|
183
181
|
level: "error",
|
|
184
182
|
ts: Date.now(),
|
|
185
183
|
source: this.CLASS_NAME,
|
|
@@ -200,7 +198,7 @@ class FastifyWebServer {
|
|
|
200
198
|
async start() {
|
|
201
199
|
const host = this._options?.host ?? FastifyWebServer._DEFAULT_HOST;
|
|
202
200
|
const port = this._options?.port ?? FastifyWebServer._DEFAULT_PORT;
|
|
203
|
-
await this.
|
|
201
|
+
await this._logging?.log({
|
|
204
202
|
level: "info",
|
|
205
203
|
ts: Date.now(),
|
|
206
204
|
source: this.CLASS_NAME,
|
|
@@ -215,7 +213,7 @@ class FastifyWebServer {
|
|
|
215
213
|
await this._fastify.listen({ port, host });
|
|
216
214
|
const addresses = this._fastify.addresses();
|
|
217
215
|
const protocol = core.Is.object(this._fastify.initialConfig.https) ? "https://" : "http://";
|
|
218
|
-
await this.
|
|
216
|
+
await this._logging?.log({
|
|
219
217
|
level: "info",
|
|
220
218
|
ts: Date.now(),
|
|
221
219
|
source: this.CLASS_NAME,
|
|
@@ -229,7 +227,7 @@ class FastifyWebServer {
|
|
|
229
227
|
this._started = true;
|
|
230
228
|
}
|
|
231
229
|
catch (err) {
|
|
232
|
-
await this.
|
|
230
|
+
await this._logging?.log({
|
|
233
231
|
level: "error",
|
|
234
232
|
ts: Date.now(),
|
|
235
233
|
source: this.CLASS_NAME,
|
|
@@ -247,7 +245,7 @@ class FastifyWebServer {
|
|
|
247
245
|
if (this._started) {
|
|
248
246
|
this._started = false;
|
|
249
247
|
await this._fastify.close();
|
|
250
|
-
await this.
|
|
248
|
+
await this._logging?.log({
|
|
251
249
|
level: "info",
|
|
252
250
|
ts: Date.now(),
|
|
253
251
|
source: this.CLASS_NAME,
|
|
@@ -268,7 +266,7 @@ class FastifyWebServer {
|
|
|
268
266
|
if (!path.startsWith("/")) {
|
|
269
267
|
path = `/${path}`;
|
|
270
268
|
}
|
|
271
|
-
await this.
|
|
269
|
+
await this._logging?.log({
|
|
272
270
|
level: "info",
|
|
273
271
|
ts: Date.now(),
|
|
274
272
|
source: this.CLASS_NAME,
|
|
@@ -295,7 +293,7 @@ class FastifyWebServer {
|
|
|
295
293
|
const pathParts = path.split("/");
|
|
296
294
|
const namespace = `/${pathParts[0]}`;
|
|
297
295
|
const topic = pathParts.slice(1).join("/");
|
|
298
|
-
await this.
|
|
296
|
+
await this._logging?.log({
|
|
299
297
|
level: "info",
|
|
300
298
|
ts: Date.now(),
|
|
301
299
|
source: this.CLASS_NAME,
|
|
@@ -465,7 +463,7 @@ class FastifyWebServer {
|
|
|
465
463
|
}
|
|
466
464
|
}
|
|
467
465
|
catch (err) {
|
|
468
|
-
this.
|
|
466
|
+
this._logging?.log({
|
|
469
467
|
level: "error",
|
|
470
468
|
ts: Date.now(),
|
|
471
469
|
source: this.CLASS_NAME,
|
package/dist/esm/index.mjs
CHANGED
|
@@ -53,7 +53,7 @@ class FastifyWebServer {
|
|
|
53
53
|
* The logging component.
|
|
54
54
|
* @internal
|
|
55
55
|
*/
|
|
56
|
-
|
|
56
|
+
_logging;
|
|
57
57
|
/**
|
|
58
58
|
* The options for the server.
|
|
59
59
|
* @internal
|
|
@@ -90,9 +90,7 @@ class FastifyWebServer {
|
|
|
90
90
|
*/
|
|
91
91
|
constructor(options) {
|
|
92
92
|
this._loggingComponentType = options?.loggingComponentType;
|
|
93
|
-
this.
|
|
94
|
-
? ComponentFactory.get(options.loggingComponentType)
|
|
95
|
-
: undefined;
|
|
93
|
+
this._logging = ComponentFactory.getIfExists(options?.loggingComponentType ?? "logging");
|
|
96
94
|
this._fastify = Fastify({
|
|
97
95
|
maxParamLength: 2000,
|
|
98
96
|
...options?.config?.web
|
|
@@ -132,7 +130,7 @@ class FastifyWebServer {
|
|
|
132
130
|
if (Is.arrayValue(socketRoutes) && !Is.arrayValue(socketRouteProcessors)) {
|
|
133
131
|
throw new GeneralError(this.CLASS_NAME, "noSocketProcessors");
|
|
134
132
|
}
|
|
135
|
-
await this.
|
|
133
|
+
await this._logging?.log({
|
|
136
134
|
level: "info",
|
|
137
135
|
ts: Date.now(),
|
|
138
136
|
source: this.CLASS_NAME,
|
|
@@ -177,7 +175,7 @@ class FastifyWebServer {
|
|
|
177
175
|
err = errorAndCode.error;
|
|
178
176
|
httpStatusCode = errorAndCode.httpStatusCode;
|
|
179
177
|
}
|
|
180
|
-
await this.
|
|
178
|
+
await this._logging?.log({
|
|
181
179
|
level: "error",
|
|
182
180
|
ts: Date.now(),
|
|
183
181
|
source: this.CLASS_NAME,
|
|
@@ -198,7 +196,7 @@ class FastifyWebServer {
|
|
|
198
196
|
async start() {
|
|
199
197
|
const host = this._options?.host ?? FastifyWebServer._DEFAULT_HOST;
|
|
200
198
|
const port = this._options?.port ?? FastifyWebServer._DEFAULT_PORT;
|
|
201
|
-
await this.
|
|
199
|
+
await this._logging?.log({
|
|
202
200
|
level: "info",
|
|
203
201
|
ts: Date.now(),
|
|
204
202
|
source: this.CLASS_NAME,
|
|
@@ -213,7 +211,7 @@ class FastifyWebServer {
|
|
|
213
211
|
await this._fastify.listen({ port, host });
|
|
214
212
|
const addresses = this._fastify.addresses();
|
|
215
213
|
const protocol = Is.object(this._fastify.initialConfig.https) ? "https://" : "http://";
|
|
216
|
-
await this.
|
|
214
|
+
await this._logging?.log({
|
|
217
215
|
level: "info",
|
|
218
216
|
ts: Date.now(),
|
|
219
217
|
source: this.CLASS_NAME,
|
|
@@ -227,7 +225,7 @@ class FastifyWebServer {
|
|
|
227
225
|
this._started = true;
|
|
228
226
|
}
|
|
229
227
|
catch (err) {
|
|
230
|
-
await this.
|
|
228
|
+
await this._logging?.log({
|
|
231
229
|
level: "error",
|
|
232
230
|
ts: Date.now(),
|
|
233
231
|
source: this.CLASS_NAME,
|
|
@@ -245,7 +243,7 @@ class FastifyWebServer {
|
|
|
245
243
|
if (this._started) {
|
|
246
244
|
this._started = false;
|
|
247
245
|
await this._fastify.close();
|
|
248
|
-
await this.
|
|
246
|
+
await this._logging?.log({
|
|
249
247
|
level: "info",
|
|
250
248
|
ts: Date.now(),
|
|
251
249
|
source: this.CLASS_NAME,
|
|
@@ -266,7 +264,7 @@ class FastifyWebServer {
|
|
|
266
264
|
if (!path.startsWith("/")) {
|
|
267
265
|
path = `/${path}`;
|
|
268
266
|
}
|
|
269
|
-
await this.
|
|
267
|
+
await this._logging?.log({
|
|
270
268
|
level: "info",
|
|
271
269
|
ts: Date.now(),
|
|
272
270
|
source: this.CLASS_NAME,
|
|
@@ -293,7 +291,7 @@ class FastifyWebServer {
|
|
|
293
291
|
const pathParts = path.split("/");
|
|
294
292
|
const namespace = `/${pathParts[0]}`;
|
|
295
293
|
const topic = pathParts.slice(1).join("/");
|
|
296
|
-
await this.
|
|
294
|
+
await this._logging?.log({
|
|
297
295
|
level: "info",
|
|
298
296
|
ts: Date.now(),
|
|
299
297
|
source: this.CLASS_NAME,
|
|
@@ -463,7 +461,7 @@ class FastifyWebServer {
|
|
|
463
461
|
}
|
|
464
462
|
}
|
|
465
463
|
catch (err) {
|
|
466
|
-
this.
|
|
464
|
+
this._logging?.log({
|
|
467
465
|
level: "error",
|
|
468
466
|
ts: Date.now(),
|
|
469
467
|
source: this.CLASS_NAME,
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @twin.org/api-server-fastify - Changelog
|
|
2
2
|
|
|
3
|
+
## [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)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* logging naming consistency ([a4a6ef2](https://github.com/twinfoundation/api/commit/a4a6ef2de5049045589eb78b177ff62e744bde9d))
|
|
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.6 to 0.0.2-next.7
|
|
16
|
+
* @twin.org/api-models bumped from 0.0.2-next.6 to 0.0.2-next.7
|
|
17
|
+
* @twin.org/api-processors bumped from 0.0.2-next.6 to 0.0.2-next.7
|
|
18
|
+
|
|
3
19
|
## [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
20
|
|
|
5
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.
|
|
3
|
+
"version": "0.0.2-next.7",
|
|
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.
|
|
20
|
-
"@twin.org/api-models": "0.0.2-next.
|
|
21
|
-
"@twin.org/api-processors": "0.0.2-next.
|
|
19
|
+
"@twin.org/api-core": "0.0.2-next.7",
|
|
20
|
+
"@twin.org/api-models": "0.0.2-next.7",
|
|
21
|
+
"@twin.org/api-processors": "0.0.2-next.7",
|
|
22
22
|
"@twin.org/core": "next",
|
|
23
23
|
"@twin.org/logging-models": "next",
|
|
24
24
|
"@twin.org/nameof": "next",
|