@rest-vir/run-service 1.2.2 → 1.2.4
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.
|
@@ -100,7 +100,7 @@ async function matchOrigin(endpoint, origin) {
|
|
|
100
100
|
return undefined;
|
|
101
101
|
}
|
|
102
102
|
else if (endpointRequirement === true) {
|
|
103
|
-
return origin;
|
|
103
|
+
return origin || AnyOrigin;
|
|
104
104
|
}
|
|
105
105
|
/** If the endpoint requirement is `undefined`, then we check the service requirement. */
|
|
106
106
|
const serviceRequirement = await checkOriginRequirement(origin, endpoint.service.requiredClientOrigin);
|
|
@@ -111,7 +111,7 @@ async function matchOrigin(endpoint, origin) {
|
|
|
111
111
|
return undefined;
|
|
112
112
|
}
|
|
113
113
|
else if (serviceRequirement === true) {
|
|
114
|
-
return origin;
|
|
114
|
+
return origin || AnyOrigin;
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
117
117
|
* If the service requirement is `undefined`, something went wrong because service definitions
|
|
@@ -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.4",
|
|
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.34.1",
|
|
43
|
+
"@augment-vir/common": "^31.34.1",
|
|
44
|
+
"@augment-vir/node": "^31.34.1",
|
|
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": "^7.4.
|
|
51
|
-
"fastify": "^5.
|
|
47
|
+
"@rest-vir/define-service": "^1.2.4",
|
|
48
|
+
"@rest-vir/implement-service": "^1.2.4",
|
|
49
|
+
"cluster-vir": "^1.0.1",
|
|
50
|
+
"date-vir": "^7.4.2",
|
|
51
|
+
"fastify": "^5.6.0",
|
|
52
52
|
"light-my-request": "^6.6.0",
|
|
53
53
|
"portfinder": "^1.0.37",
|
|
54
54
|
"type-fest": "^4.41.0",
|
|
55
|
-
"url-vir": "^2.1.
|
|
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.34.1",
|
|
59
|
+
"@fastify/multipart": "^9.2.1",
|
|
60
60
|
"@types/connect": "^3.4.38",
|
|
61
|
-
"@types/node": "^24.3.
|
|
61
|
+
"@types/node": "^24.3.1",
|
|
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.3.2"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
69
|
"@augment-vir/test": ">=30",
|