@rest-vir/run-service 0.17.1 → 0.18.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.
|
@@ -63,6 +63,10 @@ export async function preHandler(request, response, service, server, attachId) {
|
|
|
63
63
|
response.send('Invalid body.');
|
|
64
64
|
return undefined;
|
|
65
65
|
}
|
|
66
|
+
const searchParams = handleSearchParams({ request, route });
|
|
67
|
+
if (!('data' in searchParams)) {
|
|
68
|
+
return handleHandlerResult(searchParams, response);
|
|
69
|
+
}
|
|
66
70
|
const contextParams = {
|
|
67
71
|
method: assertWrap.isEnumValue(request.method.toUpperCase(), HttpMethod),
|
|
68
72
|
request,
|
|
@@ -73,11 +77,8 @@ export async function preHandler(request, response, service, server, attachId) {
|
|
|
73
77
|
endpointDefinition: endpointDefinition,
|
|
74
78
|
webSocketDefinition: webSocketDefinition,
|
|
75
79
|
server,
|
|
80
|
+
searchParams: searchParams.data,
|
|
76
81
|
};
|
|
77
|
-
const searchParams = handleSearchParams({ request, route });
|
|
78
|
-
if (!('data' in searchParams)) {
|
|
79
|
-
return handleHandlerResult(searchParams, response);
|
|
80
|
-
}
|
|
81
82
|
try {
|
|
82
83
|
const contextOutput = await service.createContext?.(contextParams);
|
|
83
84
|
if (contextOutput?.reject) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Overwrite, type PartialWithUndefined, type SelectFrom } from '@augment-vir/common';
|
|
2
|
-
import { type ClientWebSocket, type CollapsedConnectWebSocketParams, type CollapsedFetchEndpointParams, type EndpointDefinition, type WebSocketDefinition } from '@rest-vir/define-service';
|
|
2
|
+
import { type ClientWebSocket, type CollapsedConnectWebSocketParams, type CollapsedFetchEndpointParams, type EndpointDefinition, type GenericEndpointDefinition, type GenericWebSocketDefinition, type WebSocketDefinition } from '@rest-vir/define-service';
|
|
3
3
|
import { type GenericServiceImplementation } from '@rest-vir/implement-service';
|
|
4
4
|
import { type FastifyInstance } from 'fastify';
|
|
5
5
|
import { type HandleRouteOptions } from '../handle-request/endpoint-handler.js';
|
|
@@ -225,7 +225,7 @@ export type ConnectTestWebSocket<WebSocketToTest extends WebSocketDefinition> =
|
|
|
225
225
|
export type FetchTestService<Service extends SelectFrom<GenericServiceImplementation, {
|
|
226
226
|
endpoints: true;
|
|
227
227
|
}>> = {
|
|
228
|
-
[EndpointPath in keyof Service['endpoints']]: Service['endpoints'][EndpointPath] extends
|
|
228
|
+
[EndpointPath in keyof Service['endpoints']]: Service['endpoints'][EndpointPath] extends GenericEndpointDefinition ? FetchTestEndpoint<Service['endpoints'][EndpointPath]> : never;
|
|
229
229
|
};
|
|
230
230
|
/**
|
|
231
231
|
* Type for the `connectWebSocket` function provided by {@link testService} and
|
|
@@ -238,7 +238,7 @@ export type FetchTestService<Service extends SelectFrom<GenericServiceImplementa
|
|
|
238
238
|
export type ConnectTestServiceWebSocket<Service extends SelectFrom<GenericServiceImplementation, {
|
|
239
239
|
webSockets: true;
|
|
240
240
|
}>> = {
|
|
241
|
-
[WebSocketPath in keyof Service['webSockets']]: Service['webSockets'][WebSocketPath] extends
|
|
241
|
+
[WebSocketPath in keyof Service['webSockets']]: Service['webSockets'][WebSocketPath] extends GenericWebSocketDefinition ? ConnectTestWebSocket<Service['webSockets'][WebSocketPath]> : never;
|
|
242
242
|
};
|
|
243
243
|
/**
|
|
244
244
|
* Options for {@link testService}.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rest-vir/run-service",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.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",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"@augment-vir/common": "^31.16.0",
|
|
44
44
|
"@augment-vir/node": "^31.16.0",
|
|
45
45
|
"@fastify/websocket": "^11.0.2",
|
|
46
|
-
"@rest-vir/define-service": "^0.
|
|
47
|
-
"@rest-vir/implement-service": "^0.
|
|
46
|
+
"@rest-vir/define-service": "^0.18.0",
|
|
47
|
+
"@rest-vir/implement-service": "^0.18.0",
|
|
48
48
|
"cluster-vir": "^0.1.0",
|
|
49
49
|
"date-vir": "^7.3.1",
|
|
50
50
|
"fastify": "^5.3.2",
|