Skip to main content

Module: @ts-rest/next

Classes

Type Aliases

InitClientArgs

Ƭ InitClientArgs: ClientArgs & { throwOnUnknownStatus?: boolean }

Defined in

libs/ts-rest/next/src/lib/next-client.ts:37


InitClientReturn

Ƭ InitClientReturn<T, TClientArgs>: RecursiveProxyObj<T, TClientArgs>

Type parameters

NameType
Textends AppRouter
TClientArgsextends ClientArgs

Defined in

libs/ts-rest/next/src/lib/next-client.ts:32


RouterImplementation

Ƭ RouterImplementation<T>: { [TKey in keyof T]: T[TKey] extends AppRouter ? RouterImplementation<T[TKey]> : T[TKey] extends AppRoute ? AppRouteImplementation<T[TKey]> : never }

Type parameters

NameType
Textends AppRouter

Defined in

libs/ts-rest/next/src/lib/ts-rest-next.ts:41

Variables

RequestValidationErrorSchema

Const RequestValidationErrorSchema: ZodObject<{ issues: ZodArray<ZodObject<{ code: ZodNativeEnum<{ custom: "custom" ; invalid_arguments: "invalid_arguments" ; invalid_date: "invalid_date" ; invalid_enum_value: "invalid_enum_value" ; invalid_intersection_types: "invalid_intersection_types" ; invalid_literal: "invalid_literal" ; invalid_return_type: "invalid_return_type" ; invalid_string: "invalid_string" ; invalid_type: "invalid_type" ; invalid_union: "invalid_union" ; invalid_union_discriminator: "invalid_union_discriminator" ; not_finite: "not_finite" ; not_multiple_of: "not_multiple_of" ; too_big: "too_big" ; too_small: "too_small" ; unrecognized_keys: "unrecognized_keys" }> ; message: ZodOptional<ZodString> ; path: ZodArray<ZodUnion<[ZodString, ZodNumber]>, "many"> }, "strip", ZodAny, objectOutputType<{ code: ZodNativeEnum<{ custom: "custom" ; invalid_arguments: "invalid_arguments" ; invalid_date: "invalid_date" ; invalid_enum_value: "invalid_enum_value" ; invalid_intersection_types: "invalid_intersection_types" ; invalid_literal: "invalid_literal" ; invalid_return_type: "invalid_return_type" ; invalid_string: "invalid_string" ; invalid_type: "invalid_type" ; invalid_union: "invalid_union" ; invalid_union_discriminator: "invalid_union_discriminator" ; not_finite: "not_finite" ; not_multiple_of: "not_multiple_of" ; too_big: "too_big" ; too_small: "too_small" ; unrecognized_keys: "unrecognized_keys" }> ; message: ZodOptional<ZodString> ; path: ZodArray<ZodUnion<[ZodString, ZodNumber]>, "many"> }, ZodAny, "strip">, objectInputType<{ code: ZodNativeEnum<{ custom: "custom" ; invalid_arguments: "invalid_arguments" ; invalid_date: "invalid_date" ; invalid_enum_value: "invalid_enum_value" ; invalid_intersection_types: "invalid_intersection_types" ; invalid_literal: "invalid_literal" ; invalid_return_type: "invalid_return_type" ; invalid_string: "invalid_string" ; invalid_type: "invalid_type" ; invalid_union: "invalid_union" ; invalid_union_discriminator: "invalid_union_discriminator" ; not_finite: "not_finite" ; not_multiple_of: "not_multiple_of" ; too_big: "too_big" ; too_small: "too_small" ; unrecognized_keys: "unrecognized_keys" }> ; message: ZodOptional<ZodString> ; path: ZodArray<ZodUnion<[ZodString, ZodNumber]>, "many"> }, ZodAny, "strip">>, "many"> ; name: ZodLiteral<"ZodError"> }, "strip", ZodTypeAny, { issues: objectOutputType<{ code: ZodNativeEnum<{ custom: "custom" ; invalid_arguments: "invalid_arguments" ; invalid_date: "invalid_date" ; invalid_enum_value: "invalid_enum_value" ; invalid_intersection_types: "invalid_intersection_types" ; invalid_literal: "invalid_literal" ; invalid_return_type: "invalid_return_type" ; invalid_string: "invalid_string" ; invalid_type: "invalid_type" ; invalid_union: "invalid_union" ; invalid_union_discriminator: "invalid_union_discriminator" ; not_finite: "not_finite" ; not_multiple_of: "not_multiple_of" ; too_big: "too_big" ; too_small: "too_small" ; unrecognized_keys: "unrecognized_keys" }> ; message: ZodOptional<ZodString> ; path: ZodArray<ZodUnion<[ZodString, ZodNumber]>, "many"> }, ZodAny, "strip">[] ; name: "ZodError" }, { issues: objectInputType<{ code: ZodNativeEnum<{ custom: "custom" ; invalid_arguments: "invalid_arguments" ; invalid_date: "invalid_date" ; invalid_enum_value: "invalid_enum_value" ; invalid_intersection_types: "invalid_intersection_types" ; invalid_literal: "invalid_literal" ; invalid_return_type: "invalid_return_type" ; invalid_string: "invalid_string" ; invalid_type: "invalid_type" ; invalid_union: "invalid_union" ; invalid_union_discriminator: "invalid_union_discriminator" ; not_finite: "not_finite" ; not_multiple_of: "not_multiple_of" ; too_big: "too_big" ; too_small: "too_small" ; unrecognized_keys: "unrecognized_keys" }> ; message: ZodOptional<ZodString> ; path: ZodArray<ZodUnion<[ZodString, ZodNumber]>, "many"> }, ZodAny, "strip">[] ; name: "ZodError" }> = ZodErrorSchema

Defined in

libs/ts-rest/next/src/lib/ts-rest-next.ts:32

Functions

createNextRoute

createNextRoute<T>(appRouter, implementation): T extends AppRouter ? RouterImplementation<T> : T extends AppRoute ? AppRouteImplementation<T> : never

Create the implementation for a given AppRouter.

Type parameters

NameType
Textends AppRoute | AppRouter

Parameters

NameTypeDescription
appRouterTAppRouter
implementationT extends AppRouter ? RouterImplementation<T> : T extends AppRoute ? AppRouteImplementation<T> : neverImplementation of the AppRouter, e.g. your API controllers

Returns

T extends AppRouter ? RouterImplementation<T> : T extends AppRoute ? AppRouteImplementation<T> : never

Defined in

libs/ts-rest/next/src/lib/ts-rest-next.ts:176


createNextRouter

createNextRouter<T>(routes, obj, options?): (req: NextApiRequest, res: NextApiResponse) => Promise<void | NextApiResponse<any>>

Turn a completed set of Next routes into a Next.js compatible route.

Should be exported from your [...ts-rest].tsx file.

e.g.

export default createNextRouter(contract, implementation);

Type parameters

NameType
Textends AppRouter

Parameters

NameType
routesT
objRouterImplementation<T>
options?CreateNextRouterOptions

Returns

fn

▸ (req, res): Promise<void | NextApiResponse<any>>

Parameters
NameType
reqNextApiRequest
resNextApiResponse
Returns

Promise<void | NextApiResponse<any>>

Defined in

libs/ts-rest/next/src/lib/ts-rest-next.ts:201


createSingleRouteHandler

createSingleRouteHandler<T>(appRoute, implementationHandler, options?): (req: NextApiRequest, res: NextApiResponse) => Promise<void | NextApiResponse<any>>

Turn a contract route and a handler into a Next.js compatible handler Should be exported from your pages/api/path/to/handler.tsx file.

e.g.

export default createNextRouter(contract, implementationHandler);

Type parameters

NameType
Textends AppRoute

Parameters

NameType
appRouteT
implementationHandlerAppRouteImplementation<T>
options?CreateNextRouterOptions

Returns

fn

▸ (req, res): Promise<void | NextApiResponse<any>>

Parameters
NameType
reqNextApiRequest
resNextApiResponse
Returns

Promise<void | NextApiResponse<any>>

Defined in

libs/ts-rest/next/src/lib/ts-rest-next.ts:238


initNextClient

initNextClient<T, TClientArgs>(router, args): RecursiveProxyObj<T, TClientArgs>

Type parameters

NameType
Textends AppRouter
TClientArgsextends InitClientArgs

Parameters

NameType
routerT
argsTClientArgs

Returns

RecursiveProxyObj<T, TClientArgs>

Deprecated

use initClient from @ts-rest/core instead

Defined in

libs/ts-rest/next/src/lib/next-client.ts:48


isAppRouteWithImplementation

isAppRouteWithImplementation(obj): obj is any

Parameters

NameType
objany

Returns

obj is any

Defined in

libs/ts-rest/next/src/lib/ts-rest-next.ts:97