@riddl/core 0.1.0 → 0.1.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.
package/dist/utils.js CHANGED
@@ -3,6 +3,11 @@ export const recursiveAwait = (obj) => {
3
3
  if (obj instanceof Promise) {
4
4
  return obj.then(recursiveAwait);
5
5
  }
6
+ else if (obj instanceof Date) {
7
+ // `Date` is an `Object`, but `Object.keys(new Date())` is [] — without this branch,
8
+ // dates become `{}` in API responses after the plain-object walk below.
9
+ return obj;
10
+ }
6
11
  else if (obj instanceof Array) {
7
12
  return Promise.all(obj.map(recursiveAwait));
8
13
  }
@@ -28,7 +28,9 @@ export const parseBody = async (req, module) => {
28
28
  const clonedRequest = req.clone();
29
29
  // JSON body
30
30
  if ((_a = clonedRequest.headers.get("content-type")) === null || _a === void 0 ? void 0 : _a.startsWith("application/json")) {
31
- body = clonedRequest.json().catch(() => { throw error(400, "Invalid JSON body"); });
31
+ body = await clonedRequest.json().catch(() => {
32
+ throw error(400, "Invalid JSON body");
33
+ });
32
34
  }
33
35
  // Form body
34
36
  else if (((_b = clonedRequest.headers
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riddl/core",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "dependencies": {