@rest-vir/run-service 1.5.0 → 1.5.2

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,7 +63,11 @@ function buildStandardCorsHeaders(matchedOrigin, customHeaders) {
63
63
  };
64
64
  }
65
65
  }
66
- const accessControlMaxAgeValue = String(convertDuration({ hours: 1 }, { seconds: true }).seconds);
66
+ const accessControlMaxAgeValue = String(convertDuration({
67
+ hours: 1,
68
+ }, {
69
+ seconds: true,
70
+ }).seconds);
67
71
  const contentLengthHeaders = {
68
72
  /**
69
73
  * Safari (and potentially other browsers) need content-length 0 for 204 or it will hang waiting
@@ -37,7 +37,7 @@ export async function handleEndpointRequest({ endpoint, request, response, attac
37
37
  if (!endpointResult.statusCode) {
38
38
  throw new RestVirHandlerError(endpoint, 'Missing response status code.');
39
39
  }
40
- if (isErrorHttpStatus(endpointResult.statusCode)) {
40
+ else if (isErrorHttpStatus(endpointResult.statusCode)) {
41
41
  endpoint.service.logger.error(new RestVirHandlerError(endpoint, `Endpoint implementation returned error status: ${endpointResult.statusCode}`, endpointResult.statusCode));
42
42
  return {
43
43
  statusCode: endpointResult.statusCode,
@@ -50,7 +50,9 @@ export async function handleEndpointRequest({ endpoint, request, response, attac
50
50
  throw new RestVirHandlerError(endpoint, 'Got response data but none was expected.');
51
51
  }
52
52
  if (!endpoint.bypassResponseValidation) {
53
- assertValidShape(endpointResult.responseData, endpoint.responseDataShape, { allowExtraKeys: true }, 'invalid response data');
53
+ assertValidShape(endpointResult.responseData, endpoint.responseDataShape, {
54
+ allowExtraKeys: true,
55
+ }, 'invalid response data');
54
56
  }
55
57
  return {
56
58
  headers: {
@@ -73,7 +73,10 @@ export async function handleRoute({ webSocket, request, response, route, attachI
73
73
  catch (error) {
74
74
  if (error instanceof RejectRequestError) {
75
75
  assert.isDefined(response, 'no response object');
76
- await handleHandlerOutput({ statusCode: error.httpStatus, body: error.responseErrorMessage }, response);
76
+ await handleHandlerOutput({
77
+ statusCode: error.httpStatus,
78
+ body: error.responseErrorMessage,
79
+ }, response);
77
80
  return;
78
81
  }
79
82
  route.service.logger.error(ensureError(error));
@@ -15,7 +15,9 @@ export function handleSearchParams({ request, route, }) {
15
15
  const shape = route.searchParamsShape;
16
16
  const validationError = shape
17
17
  ? wrapInTry(() => {
18
- assertValidShape(searchParams, shape, { allowExtraKeys: true });
18
+ assertValidShape(searchParams, shape, {
19
+ allowExtraKeys: true,
20
+ });
19
21
  return undefined;
20
22
  })
21
23
  : undefined;
@@ -53,7 +53,9 @@ export async function handleWebSocketRequest({ attachId, request, implementedWeb
53
53
  const stringRawMessage = String(rawMessage);
54
54
  message = parseJsonWithUndefined(stringRawMessage);
55
55
  if (implementedWebSocket.messageFromClientShape) {
56
- assertValidShape(message, implementedWebSocket.messageFromClientShape, { allowExtraKeys: true }, 'Invalid message send shape.');
56
+ assertValidShape(message, implementedWebSocket.messageFromClientShape, {
57
+ allowExtraKeys: true,
58
+ }, 'Invalid message send shape.');
57
59
  }
58
60
  else if (message) {
59
61
  throw new Error(`Did not expect any data from the client but got ${stringify(message)}.`);
@@ -74,7 +74,10 @@ export async function preHandler({ request, response, service, server, attachId,
74
74
  };
75
75
  }
76
76
  attachedRestVirContext.requestData = requestData;
77
- const searchParams = handleSearchParams({ request, route });
77
+ const searchParams = handleSearchParams({
78
+ request,
79
+ route,
80
+ });
78
81
  if (!('data' in searchParams)) {
79
82
  return handleHandlerOutputWithoutSending(searchParams, response);
80
83
  }
@@ -80,7 +80,10 @@ async function startServer(service, { host, port }, fastifyPlugins) {
80
80
  await attachService(server, service, {
81
81
  throwErrorsForExternalHandling: false,
82
82
  });
83
- await server.listen({ port, host });
83
+ await server.listen({
84
+ port,
85
+ host,
86
+ });
84
87
  return {
85
88
  host,
86
89
  port,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rest-vir/run-service",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
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,28 +39,28 @@
39
39
  "test:update": "npm test update"
40
40
  },
41
41
  "dependencies": {
42
- "@augment-vir/assert": "^31.59.1",
43
- "@augment-vir/common": "^31.59.1",
44
- "@augment-vir/node": "^31.59.1",
42
+ "@augment-vir/assert": "^31.68.2",
43
+ "@augment-vir/common": "^31.68.2",
44
+ "@augment-vir/node": "^31.68.2",
45
45
  "@fastify/compress": "^8.3.1",
46
46
  "@fastify/websocket": "^11.2.0",
47
- "@rest-vir/define-service": "^1.5.0",
48
- "@rest-vir/implement-service": "^1.5.0",
47
+ "@rest-vir/define-service": "^1.5.2",
48
+ "@rest-vir/implement-service": "^1.5.2",
49
49
  "cluster-vir": "^1.0.1",
50
- "date-vir": "^8.1.0",
51
- "fastify": "^5.7.4",
50
+ "date-vir": "^8.2.1",
51
+ "fastify": "^5.8.2",
52
52
  "light-my-request": "^6.6.0",
53
53
  "portfinder": "^1.0.38",
54
- "type-fest": "^5.4.3",
54
+ "type-fest": "^5.5.0",
55
55
  "url-vir": "^2.1.7"
56
56
  },
57
57
  "devDependencies": {
58
- "@augment-vir/test": "^31.59.1",
58
+ "@augment-vir/test": "^31.68.2",
59
59
  "@fastify/multipart": "^9.4.0",
60
60
  "@types/connect": "^3.4.38",
61
- "@types/node": "^25.2.0",
61
+ "@types/node": "^25.5.0",
62
62
  "@types/ws": "^8.18.1",
63
- "c8": "^10.1.3",
63
+ "c8": "^11.0.0",
64
64
  "istanbul-smart-text-reporter": "^1.1.5",
65
65
  "markdown-code-example-inserter": "^3.0.3",
66
66
  "object-shape-tester": "^6.11.0"