@veducio/keja 0.7.0 → 0.7.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veducio/keja",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "packageManager": "bun@1.4.4",
5
5
  "description": "Veducio Keja - RESTFUL Web Server, Based on Lightweight Hono Framework, Written in TypeScript, Powered by Bun",
6
6
  "license": "MIT",
@@ -60,4 +60,18 @@ describe("runMiddleware", () => {
60
60
  ).rejects.toThrow(`Middleware cannot pass reserved field ${key}`);
61
61
  }
62
62
  });
63
+
64
+ it("rejects next() when the rest of the chain does not return a Response", async () => {
65
+ const step = defineMiddleware(async ({ next }) => {
66
+ const response = await next();
67
+ return response;
68
+ });
69
+ await expect(
70
+ runMiddleware(
71
+ [{ definition: step, allowFields: true }],
72
+ context,
73
+ () => undefined as never,
74
+ ),
75
+ ).rejects.toThrow("next() must resolve to a Response");
76
+ });
63
77
  });
@@ -128,7 +128,11 @@ export async function runMiddleware(
128
128
  }
129
129
  Object.assign(fields, passed);
130
130
  }
131
- return dispatch();
131
+ const nextResponse = await dispatch();
132
+ if (!(nextResponse instanceof Response)) {
133
+ throw new Error("next() must resolve to a Response");
134
+ }
135
+ return nextResponse;
132
136
  },
133
137
  });
134
138
  if (!(response instanceof Response)) {