@twin.org/api-server-fastify 0.0.1-next.24 → 0.0.1-next.25
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 +19 -5
- package/dist/esm/index.mjs +19 -5
- package/docs/changelog.md +1 -1
- package/locales/en.json +2 -1
- package/package.json +3 -3
package/dist/cjs/index.cjs
CHANGED
|
@@ -290,7 +290,7 @@ class FastifyWebServer {
|
|
|
290
290
|
ts: Date.now(),
|
|
291
291
|
source: this.CLASS_NAME,
|
|
292
292
|
message: `${FastifyWebServer._CLASS_NAME_CAMEL_CASE}.socketRouteAdded`,
|
|
293
|
-
data: { route: path }
|
|
293
|
+
data: { route: `/${path}` }
|
|
294
294
|
});
|
|
295
295
|
const socketNamespace = io.of(`/${pathParts[0]}`);
|
|
296
296
|
const topic = pathParts.slice(1).join("/");
|
|
@@ -448,12 +448,26 @@ class FastifyWebServer {
|
|
|
448
448
|
// Custom emit method which will also call the post processors
|
|
449
449
|
const postProcessEmit = async (topic, response, responseProcessorState) => {
|
|
450
450
|
await responseEmitter(topic, response);
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
451
|
+
try {
|
|
452
|
+
// The post processors are called after the response has been emitted
|
|
453
|
+
for (const postSocketRouteProcessor of socketRouteProcessors) {
|
|
454
|
+
if (core.Is.function(postSocketRouteProcessor.post)) {
|
|
455
|
+
await postSocketRouteProcessor.post(httpServerRequest, response, socketRoute, httpRequestIdentity, responseProcessorState);
|
|
456
|
+
}
|
|
455
457
|
}
|
|
456
458
|
}
|
|
459
|
+
catch (err) {
|
|
460
|
+
this._loggingConnector?.log({
|
|
461
|
+
level: "error",
|
|
462
|
+
ts: Date.now(),
|
|
463
|
+
source: this.CLASS_NAME,
|
|
464
|
+
message: `${FastifyWebServer._CLASS_NAME_CAMEL_CASE}.postProcessorError`,
|
|
465
|
+
error: core.BaseError.fromError(err),
|
|
466
|
+
data: {
|
|
467
|
+
route: socketRoute.path
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
}
|
|
457
471
|
};
|
|
458
472
|
try {
|
|
459
473
|
for (const socketRouteProcessor of socketRouteProcessors) {
|
package/dist/esm/index.mjs
CHANGED
|
@@ -288,7 +288,7 @@ class FastifyWebServer {
|
|
|
288
288
|
ts: Date.now(),
|
|
289
289
|
source: this.CLASS_NAME,
|
|
290
290
|
message: `${FastifyWebServer._CLASS_NAME_CAMEL_CASE}.socketRouteAdded`,
|
|
291
|
-
data: { route: path }
|
|
291
|
+
data: { route: `/${path}` }
|
|
292
292
|
});
|
|
293
293
|
const socketNamespace = io.of(`/${pathParts[0]}`);
|
|
294
294
|
const topic = pathParts.slice(1).join("/");
|
|
@@ -446,12 +446,26 @@ class FastifyWebServer {
|
|
|
446
446
|
// Custom emit method which will also call the post processors
|
|
447
447
|
const postProcessEmit = async (topic, response, responseProcessorState) => {
|
|
448
448
|
await responseEmitter(topic, response);
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
449
|
+
try {
|
|
450
|
+
// The post processors are called after the response has been emitted
|
|
451
|
+
for (const postSocketRouteProcessor of socketRouteProcessors) {
|
|
452
|
+
if (Is.function(postSocketRouteProcessor.post)) {
|
|
453
|
+
await postSocketRouteProcessor.post(httpServerRequest, response, socketRoute, httpRequestIdentity, responseProcessorState);
|
|
454
|
+
}
|
|
453
455
|
}
|
|
454
456
|
}
|
|
457
|
+
catch (err) {
|
|
458
|
+
this._loggingConnector?.log({
|
|
459
|
+
level: "error",
|
|
460
|
+
ts: Date.now(),
|
|
461
|
+
source: this.CLASS_NAME,
|
|
462
|
+
message: `${FastifyWebServer._CLASS_NAME_CAMEL_CASE}.postProcessorError`,
|
|
463
|
+
error: BaseError.fromError(err),
|
|
464
|
+
data: {
|
|
465
|
+
route: socketRoute.path
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
}
|
|
455
469
|
};
|
|
456
470
|
try {
|
|
457
471
|
for (const socketRouteProcessor of socketRouteProcessors) {
|
package/docs/changelog.md
CHANGED
package/locales/en.json
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"restRouteAdded": "Added REST route \"{route}\" \"{method}\"",
|
|
10
10
|
"socketRouteAdded": "Added socket route \"{route}\"",
|
|
11
11
|
"noRestProcessors": "You must configure at least one REST processor",
|
|
12
|
-
"noSocketProcessors": "You must configure at least one socket 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}\""
|
|
13
14
|
}
|
|
14
15
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/api-server-fastify",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.25",
|
|
4
4
|
"description": "Use Fastify as the core web server for APIs",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@fastify/compress": "8.0.1",
|
|
18
18
|
"@fastify/cors": "10.0.1",
|
|
19
|
-
"@twin.org/api-core": "0.0.1-next.
|
|
20
|
-
"@twin.org/api-models": "0.0.1-next.
|
|
19
|
+
"@twin.org/api-core": "0.0.1-next.25",
|
|
20
|
+
"@twin.org/api-models": "0.0.1-next.25",
|
|
21
21
|
"@twin.org/core": "next",
|
|
22
22
|
"@twin.org/logging-models": "next",
|
|
23
23
|
"@twin.org/nameof": "next",
|