UNPKG

honestjs

Version:

HonestJS - a modern web framework built on top of Hono

17 lines (16 loc) 766 B
import type { Context } from 'hono'; /** * Creates a parameter decorator factory for route handlers * @template T - The type of the parameter value after transformation * @param type - The type identifier for the parameter * @param factory - Optional function to transform the parameter value * @returns A parameter decorator function that registers parameter metadata * @example * ```ts * const Body = createParamDecorator('body', async (data, ctx) => { * const body = await ctx.req.json(); * return data ? body[data] : body; * }); * ``` */ export declare function createParamDecorator<T = any>(type: string, factory?: (data: any, ctx: Context) => T): (data?: any) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;