hono icon indicating copy to clipboard operation
hono copied to clipboard

Make it possible to reference context changes from previous middlewares in combine

Open kbrgl opened this issue 7 months ago • 1 comments

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();
	},
);

kbrgl avatar Jul 17 '25 00:07 kbrgl

Is anyone working on this issue?

pradeepbgs avatar Sep 22 '25 00:09 pradeepbgs