@rest-vir/run-service 0.21.0 → 0.22.0
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.
|
@@ -48,7 +48,9 @@ export async function handleEndpointRequest({ endpoint, request, response, attac
|
|
|
48
48
|
if (endpoint.responseDataShape == undefined) {
|
|
49
49
|
throw new RestVirHandlerError(endpoint, 'Got response data but none was expected.');
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
if (!endpoint.bypassResponseValidation) {
|
|
52
|
+
assertValidShape(endpointResult.responseData, endpoint.responseDataShape, { allowExtraKeys: true }, 'invalid response data');
|
|
53
|
+
}
|
|
52
54
|
return {
|
|
53
55
|
headers: {
|
|
54
56
|
'content-type': endpointResult.dataType || 'application/json',
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { assert, check } from '@augment-vir/assert';
|
|
2
2
|
import { ensureError, ensureErrorClass, extractErrorMessage, getEnumValues, getObjectTypedKeys, HttpMethod, HttpStatus, randomString, } from '@augment-vir/common';
|
|
3
|
+
import compressPlugin from '@fastify/compress';
|
|
3
4
|
import fastifyWs from '@fastify/websocket';
|
|
4
5
|
import { RestVirHandlerError, } from '@rest-vir/implement-service';
|
|
5
6
|
import { buildUrl, parseUrl } from 'url-vir';
|
|
@@ -39,6 +40,13 @@ export async function attachService(server, service, options = {}) {
|
|
|
39
40
|
if (!server.hasRequestDecorator('restVirContext')) {
|
|
40
41
|
server.decorateRequest('restVirContext');
|
|
41
42
|
}
|
|
43
|
+
await server.register(compressPlugin, {
|
|
44
|
+
encodings: [
|
|
45
|
+
'br',
|
|
46
|
+
'gzip',
|
|
47
|
+
'deflate',
|
|
48
|
+
],
|
|
49
|
+
});
|
|
42
50
|
if (!server.hasRequestDecorator('ws')) {
|
|
43
51
|
await server.register(fastifyWs, {
|
|
44
52
|
/* node:coverage ignore next 14: edge case handling */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rest-vir/run-service",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"description": "Run a service defined by @rest-vir/define-service and implemented by @rest-vir/implement-service.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rest",
|
|
@@ -42,9 +42,10 @@
|
|
|
42
42
|
"@augment-vir/assert": "^31.28.0",
|
|
43
43
|
"@augment-vir/common": "^31.28.0",
|
|
44
44
|
"@augment-vir/node": "^31.28.0",
|
|
45
|
+
"@fastify/compress": "^8.1.0",
|
|
45
46
|
"@fastify/websocket": "^11.2.0",
|
|
46
|
-
"@rest-vir/define-service": "^0.
|
|
47
|
-
"@rest-vir/implement-service": "^0.
|
|
47
|
+
"@rest-vir/define-service": "^0.22.0",
|
|
48
|
+
"@rest-vir/implement-service": "^0.22.0",
|
|
48
49
|
"cluster-vir": "^0.1.0",
|
|
49
50
|
"date-vir": "^7.4.0",
|
|
50
51
|
"fastify": "^5.4.0",
|