@rest-vir/run-service 1.2.3 → 1.2.5
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.
|
@@ -2,7 +2,7 @@ import { assertWrap } from '@augment-vir/assert';
|
|
|
2
2
|
import { ensureErrorAndPrependMessage, extractErrorMessage, getOrSet, HttpStatus, stringify, wrapInTry, } from '@augment-vir/common';
|
|
3
3
|
import { isFormDataShape, matchUrlToService, restVirServiceNameHeader, } from '@rest-vir/define-service';
|
|
4
4
|
import { HttpMethod, RestVirHandlerError, } from '@rest-vir/implement-service';
|
|
5
|
-
import { assertValidShape,
|
|
5
|
+
import { assertValidShape, checkValidShape } from 'object-shape-tester';
|
|
6
6
|
import { handleHandlerOutputWithoutSending } from './endpoint-handler.js';
|
|
7
7
|
import { handleCors } from './handle-cors.js';
|
|
8
8
|
import { handleRequestMethod } from './handle-request-method.js';
|
|
@@ -118,11 +118,10 @@ function extractRequestData(body, headers, route) {
|
|
|
118
118
|
return undefined;
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
-
if (isFormDataShape(dataShape
|
|
122
|
-
headers['content-type']?.includes('multipart/form-data')) {
|
|
121
|
+
if (isFormDataShape(dataShape) && headers['content-type']?.includes('multipart/form-data')) {
|
|
123
122
|
return body;
|
|
124
123
|
}
|
|
125
|
-
else if (!
|
|
124
|
+
else if (!checkValidShape(body, dataShape, {
|
|
126
125
|
/** Allow extra keys for forwards / backwards compatibility. */
|
|
127
126
|
allowExtraKeys: true,
|
|
128
127
|
})) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assert, check } from '@augment-vir/assert';
|
|
2
|
-
import { ensureError, ensureErrorClass, extractErrorMessage, getEnumValues, getObjectTypedKeys, HttpMethod, HttpStatus, randomString, } from '@augment-vir/common';
|
|
2
|
+
import { combineErrorMessages, ensureError, ensureErrorClass, extractErrorMessage, getEnumValues, getObjectTypedKeys, HttpMethod, HttpStatus, randomString, } from '@augment-vir/common';
|
|
3
3
|
import compressPlugin from '@fastify/compress';
|
|
4
4
|
import fastifyWs from '@fastify/websocket';
|
|
5
5
|
import { RestVirHandlerError, } from '@rest-vir/implement-service';
|
|
@@ -94,7 +94,7 @@ export async function attachService(server, service, options = {}) {
|
|
|
94
94
|
isWebSocket: undefined,
|
|
95
95
|
path: request.originalUrl,
|
|
96
96
|
service,
|
|
97
|
-
}, 'Unexpected error'));
|
|
97
|
+
}, combineErrorMessages('Unexpected error', extractErrorMessage(error))));
|
|
98
98
|
if (options.throwErrorsForExternalHandling) {
|
|
99
99
|
throw error;
|
|
100
100
|
/* node:coverage ignore next 5 */
|
|
@@ -6,7 +6,7 @@ import { type PartialWithUndefined } from '@augment-vir/common';
|
|
|
6
6
|
* @category Package : @rest-vir/run-service
|
|
7
7
|
* @package [`@rest-vir/run-service`](https://www.npmjs.com/package/@rest-vir/run-service)
|
|
8
8
|
*/
|
|
9
|
-
export declare const startServiceOptionsShape: import("object-shape-tester").
|
|
9
|
+
export declare const startServiceOptionsShape: import("object-shape-tester").Shape<{
|
|
10
10
|
/**
|
|
11
11
|
* Prevent automatically choosing an available port if the provided port is already in use. This
|
|
12
12
|
* will cause `startService` to simply crash if the given port is in use.
|
|
@@ -55,7 +55,7 @@ export declare const startServiceOptionsShape: import("object-shape-tester").Sha
|
|
|
55
55
|
* @default false
|
|
56
56
|
*/
|
|
57
57
|
debug: boolean;
|
|
58
|
-
}
|
|
58
|
+
}>;
|
|
59
59
|
/**
|
|
60
60
|
* Full options type for `startService`.
|
|
61
61
|
*
|
|
@@ -70,7 +70,7 @@ export const startServiceOptionsShape = defineShape({
|
|
|
70
70
|
*/
|
|
71
71
|
export function finalizeOptions(serviceOrigin, userOptions) {
|
|
72
72
|
const { hostname, port } = parseUrl(serviceOrigin);
|
|
73
|
-
const options = mergeDefinedProperties(startServiceOptionsShape.
|
|
73
|
+
const options = mergeDefinedProperties(startServiceOptionsShape.default, Number(port)
|
|
74
74
|
? {
|
|
75
75
|
host: hostname || undefined,
|
|
76
76
|
port: Number(port),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rest-vir/run-service",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
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",
|
|
@@ -39,31 +39,31 @@
|
|
|
39
39
|
"test:update": "npm test update"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@augment-vir/assert": "^31.
|
|
43
|
-
"@augment-vir/common": "^31.
|
|
44
|
-
"@augment-vir/node": "^31.
|
|
42
|
+
"@augment-vir/assert": "^31.40.0",
|
|
43
|
+
"@augment-vir/common": "^31.40.0",
|
|
44
|
+
"@augment-vir/node": "^31.40.0",
|
|
45
45
|
"@fastify/compress": "^8.1.0",
|
|
46
46
|
"@fastify/websocket": "^11.2.0",
|
|
47
|
-
"@rest-vir/define-service": "^1.2.
|
|
48
|
-
"@rest-vir/implement-service": "^1.2.
|
|
49
|
-
"cluster-vir": "^1.0.
|
|
50
|
-
"date-vir": "^
|
|
51
|
-
"fastify": "^5.
|
|
47
|
+
"@rest-vir/define-service": "^1.2.5",
|
|
48
|
+
"@rest-vir/implement-service": "^1.2.5",
|
|
49
|
+
"cluster-vir": "^1.0.1",
|
|
50
|
+
"date-vir": "^8.0.0",
|
|
51
|
+
"fastify": "^5.6.1",
|
|
52
52
|
"light-my-request": "^6.6.0",
|
|
53
|
-
"portfinder": "^1.0.
|
|
54
|
-
"type-fest": "^
|
|
55
|
-
"url-vir": "^2.1.
|
|
53
|
+
"portfinder": "^1.0.38",
|
|
54
|
+
"type-fest": "^5.1.0",
|
|
55
|
+
"url-vir": "^2.1.6"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@augment-vir/test": "^31.
|
|
59
|
-
"@fastify/multipart": "^9.
|
|
58
|
+
"@augment-vir/test": "^31.40.0",
|
|
59
|
+
"@fastify/multipart": "^9.2.1",
|
|
60
60
|
"@types/connect": "^3.4.38",
|
|
61
|
-
"@types/node": "^24.
|
|
61
|
+
"@types/node": "^24.7.2",
|
|
62
62
|
"@types/ws": "^8.18.1",
|
|
63
63
|
"c8": "^10.1.3",
|
|
64
64
|
"istanbul-smart-text-reporter": "^1.1.5",
|
|
65
65
|
"markdown-code-example-inserter": "^3.0.3",
|
|
66
|
-
"object-shape-tester": "^
|
|
66
|
+
"object-shape-tester": "^6.9.2"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
69
|
"@augment-vir/test": ">=30",
|