shelving 1.150.0 → 1.150.1

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.
Files changed (2) hide show
  1. package/api/Endpoint.js +4 -2
  2. package/package.json +1 -1
package/api/Endpoint.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { getResponse } from "../util/http.js";
2
- import { UNDEFINED } from "../util/validate.js";
2
+ import { UNDEFINED, getValid } from "../util/validate.js";
3
3
  /**
4
4
  * An abstract API resource definition, used to specify types for e.g. serverless functions.
5
5
  *
@@ -42,7 +42,9 @@ export class Endpoint {
42
42
  // Validate the payload against this endpoint's payload type.
43
43
  const payload = this.payload.validate(unsafePayload);
44
44
  // Call the callback with the validated payload to get the result.
45
- const result = await callback(payload, request);
45
+ const unsafeResult = await callback(payload, request);
46
+ // Validate the result against this endpoint's result type.
47
+ const result = getValid(unsafeResult, this.result);
46
48
  // Convert the result to a `Response` object.
47
49
  return getResponse(result);
48
50
  }
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "state-management",
12
12
  "query-builder"
13
13
  ],
14
- "version": "1.150.0",
14
+ "version": "1.150.1",
15
15
  "repository": "https://github.com/dhoulb/shelving",
16
16
  "author": "Dave Houlbrooke <dave@shax.com>",
17
17
  "license": "0BSD",