@riddl/core 0.1.1 → 0.2.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.
package/dist/api.js CHANGED
@@ -7,7 +7,7 @@ import { parseRouteId } from "./parser.js";
7
7
  import { buildRouter } from "./routing.js";
8
8
  import { openapiHandler, registerRoutes } from "./openapi.js";
9
9
  import { error } from "./errors.js";
10
- export const api = async ({ routeModuleMap, config, base = "/api", cors = true, registry = new OpenAPIRegistry(), }) => {
10
+ export const api = async ({ routeModuleMap, config, base = "", cors = true, registry = new OpenAPIRegistry(), }) => {
11
11
  const { routes, middlewares } = await Object.entries(routeModuleMap)
12
12
  .reduce(async (accPromise, [path, module]) => {
13
13
  var _a, _b, _c;
package/dist/openapi.js CHANGED
@@ -6,7 +6,7 @@ const openApiPath = (id, base) => id.split("/")
6
6
  .replace(/^\./, base)
7
7
  .replace(/\[(\.{3})?(.+?)\]/g, "{$2}")
8
8
  .replace(/\(.+\)\//g, "");
9
- export const registerRoutes = ({ routes, registry, base = "/api", }) => {
9
+ export const registerRoutes = ({ routes, registry, base = "", }) => {
10
10
  for (const [id, { handlers }] of Object.entries(routes)) {
11
11
  Object.entries(handlers).forEach(([methodString, module]) => {
12
12
  var _a;
@@ -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.1",
3
+ "version": "0.2.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "dependencies": {