hono
hono copied to clipboard
Make it possible to reference context changes from previous middlewares in combine
What is the feature you are proposing?
It would be great if this pattern was supported. Note how the second middleware references slug, which is typed by the first:
import { every } from "hono/combine";
import { zValidator } from "@hono/zod-validator";
import { z } from "zod";
import { HTTPException } from "hono/http-exception";
export const resolveSlugToId = every(
zValidator(
"param",
z.object({
slug: z.string().nonempty(),
}),
),
async (c, next) => {
const { slug } = c.req.valid("param");
const id = await slugToId(slug);
c.req.
await next();
},
);
Is anyone working on this issue?