Type Alias IValidatedHttpReq<TReqJson, TReqFields, TReqParams, TReqSearchParams, TReqHeaders, TReqFiles, TCookieData>

IValidatedHttpReq: {
    cookies(): TCookieData;
    cookies<
        TField extends string
        | number
        | symbol,
        TValue extends undefined | string,
    >(
        field: TField,
    ): UndefinedToNull<TValue>;
    fields(): Promise<TReqFields>;
    fields<TField extends string | number | symbol, TValue extends unknown>(
        field: TField,
    ): Promise<TValue>;
    files(): Promise<HttpReqFiles<TReqFiles>>;
    files<TField extends string | number | symbol>(
        field: TField,
    ): Promise<IHttpFileCollection>;
    headers(): TReqHeaders;
    headers<TField extends string | number | symbol, TValue extends unknown>(
        field: TField,
    ): UndefinedToNull<TValue>;
    json(): Promise<TReqJson>;
    params(): TReqParams;
    params<TField extends string | number | symbol, TValue extends unknown>(
        field: TField,
    ): UndefinedToNull<TValue>;
    searchParams(): TReqSearchParams;
    searchParams<
        TField extends string
        | number
        | symbol,
        TValue extends unknown,
    >(
        field: TField,
    ): UndefinedToNull<TValue>;
}

A validated, type-safe view of the incoming HTTP request.

Returned by withSchema, this type provides schema-validated access to all request data sources — JSON body, form fields, uploaded files, path parameters, query parameters, headers, and cookies — with full type inference from the provided schemas.

Each accessor method is overloaded: calling with no arguments returns the entire validated record, while passing a specific field name returns only that field's value (with null for undefined optional fields).

Type Parameters

  • TReqJson = unknown

    The type of the parsed JSON body.

  • TReqFields extends ReqInputs = ReqInputs

    The type of the parsed form fields.

  • TReqParams extends ReqInputs = ReqInputs

    The type of the parsed path parameters.

  • TReqSearchParams extends ReqInputs = ReqInputs

    The type of the parsed query parameters.

  • TReqHeaders extends ReqInputs = ReqInputs

    The type of the parsed headers.

  • TReqFiles extends FileInputs = FileInputs

    The expected file definitions.

  • TCookieData extends StringInputs = StringInputs

    A record mapping cookie names to their value types.

    IMPORT_PATH: "@daiso-tech/core/http-router/contracts"

Type declaration