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
Name | Type |
---|---|
T | extends AppRouter |
TClientArgs | extends 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
Name | Type |
---|---|
T | extends 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
Name | Type |
---|---|
T | extends AppRoute | AppRouter |
Parameters
Name | Type | Description |
---|---|---|
appRouter | T | AppRouter |
implementation | T extends AppRouter ? RouterImplementation <T > : T extends AppRoute ? AppRouteImplementation <T > : never | Implementation 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
Name | Type |
---|---|
T | extends AppRouter |
Parameters
Name | Type |
---|---|
routes | T |
obj | RouterImplementation <T > |
options? | CreateNextRouterOptions |
Returns
fn
▸ (req
, res
): Promise
<void
| NextApiResponse
<any
>>
Parameters
Name | Type |
---|---|
req | NextApiRequest |
res | NextApiResponse |
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
Name | Type |
---|---|
T | extends AppRoute |
Parameters
Name | Type |
---|---|
appRoute | T |
implementationHandler | AppRouteImplementation <T > |
options? | CreateNextRouterOptions |
Returns
fn
▸ (req
, res
): Promise
<void
| NextApiResponse
<any
>>
Parameters
Name | Type |
---|---|
req | NextApiRequest |
res | NextApiResponse |
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
Name | Type |
---|---|
T | extends AppRouter |
TClientArgs | extends InitClientArgs |
Parameters
Name | Type |
---|---|
router | T |
args | TClientArgs |
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
Name | Type |
---|---|
obj | any |
Returns
obj is any
Defined in
libs/ts-rest/next/src/lib/ts-rest-next.ts:97