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
Functions
createNextRoute
▸ createNextRoute<T
>(appRouter
, implementation
): T
extends AppRouter
? RecursiveRouterObj
<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 ? RecursiveRouterObj <T > : T extends AppRoute ? AppRouteImplementation <T > : never | Implementation of the AppRouter, e.g. your API controllers |
Returns
T
extends AppRouter
? RecursiveRouterObj
<T
> : T
extends AppRoute
? AppRouteImplementation
<T
> : never
Defined in
libs/ts-rest/next/src/lib/ts-rest-next.ts:171
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 | RecursiveRouterObj <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:196
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 | AppRoute |
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:237
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:92