fix: middleware regressions (#3106)

Fixes some regressions found after merging
https://github.com/denoland/fresh/pull/3086

- Missing 404 middlewares when mounting sub-apps
- revert more staticFiles logic to always require the middleware like
before
This commit is contained in:
Marvin Hagemeister
2025-07-17 15:23:27 +02:00
committed by GitHub
parent c279efa345
commit 226e250386
7 changed files with 69 additions and 71 deletions
+23
View File
@@ -412,6 +412,29 @@ Deno.test(
},
);
Deno.test("App - .mountApp() fallback route", async () => {
let called = "";
const innerApp = new App<{ text: string }>()
.use(function Inner(ctx) {
called += "_Inner";
return ctx.next();
})
.get("/", (ctx) => new Response(ctx.state.text));
const app = new App<{ text: string }>()
.use(function Outer(ctx) {
called += "Outer";
return ctx.next();
})
.mountApp("/", innerApp);
const server = new FakeServer(app.handler());
const res = await server.get("/invalid");
await res.body?.cancel();
expect(called).toEqual("Outer_Inner");
});
Deno.test("App - catches errors", async () => {
let thrownErr: unknown | null = null;
const app = new App<{ text: string }>()