Skip to content

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

@kbrgl

Description

@kbrgl

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions