Skip to main content

Module: @ts-rest/express

Classes

Interfaces

Type Aliases

AppRouteImplementation

Ƭ AppRouteImplementation<T>: T extends AppRouteMutation ? AppRouteMutationImplementation<T> : T extends AppRouteQuery ? AppRouteQueryImplementation<T> : never

Type parameters

NameType
Textends AppRoute

Defined in

libs/ts-rest/express/src/lib/types.ts:35


AppRouteMutationImplementation

Ƭ AppRouteMutationImplementation<T>: (input: ServerInferRequest<T, Express["request"][``"headers"``]> & { file: unknown ; files: unknown ; req: TsRestRequest<T> ; res: Response }) => Promise<ServerInferResponses<T>>

Type parameters

NameType
Textends AppRouteMutation

Type declaration

▸ (input): Promise<ServerInferResponses<T>>

Parameters
NameType
inputServerInferRequest<T, Express["request"][``"headers"``]> & { file: unknown ; files: unknown ; req: TsRestRequest<T> ; res: Response }
Returns

Promise<ServerInferResponses<T>>

Defined in

libs/ts-rest/express/src/lib/types.ts:26


AppRouteQueryImplementation

Ƭ AppRouteQueryImplementation<T>: (input: ServerInferRequest<T, Express["request"][``"headers"``]> & { req: TsRestRequest<T> ; res: Response }) => Promise<ServerInferResponses<T>>

Type parameters

NameType
Textends AppRouteQuery

Type declaration

▸ (input): Promise<ServerInferResponses<T>>

Parameters
NameType
inputServerInferRequest<T, Express["request"][``"headers"``]> & { req: TsRestRequest<T> ; res: Response }
Returns

Promise<ServerInferResponses<T>>

Defined in

libs/ts-rest/express/src/lib/types.ts:19


TsRestExpressOptions

Ƭ TsRestExpressOptions<T>: Object

Type parameters

NameType
Textends AppRouter

Type declaration

NameType
globalMiddleware?TsRestRequestHandler<FlattenAppRouter<T>>[]
jsonQuery?boolean
logInitialization?boolean
requestValidationErrorHandler?"default" | "combined" | (err: RequestValidationError, req: TsRestRequest<FlattenAppRouter<T>>, res: Response, next: NextFunction) => void
responseValidation?boolean

Defined in

libs/ts-rest/express/src/lib/types.ts:91


TsRestRequest

Ƭ TsRestRequest<T, F, S>: Request<"params" extends keyof S ? S["params"] : Express["request"][``"params"``], ServerInferResponseBody<F>, "body" extends keyof S ? S["body"] : Express["request"][``"body"``], "query" extends keyof S ? S["query"] : Express["request"][``"query"``]> & { headers: "headers" extends keyof S ? S["headers"] : Express["request"][``"headers"``] ; tsRestRoute: F }

Type parameters

NameType
Textends AppRouter | AppRoute
Fextends FlattenAppRouter<T> = FlattenAppRouter<T>
Sextends ServerInferRequest<F> = ServerInferRequest<F>

Defined in

libs/ts-rest/express/src/lib/types.ts:42


TsRestRequestHandler

Ƭ TsRestRequestHandler<T>: (req: TsRestRequest<T>, res: Response, next: NextFunction) => void

Type parameters

NameType
Textends AppRouter | AppRoute

Type declaration

▸ (req, res, next): void

Parameters
NameType
reqTsRestRequest<T>
resResponse
nextNextFunction
Returns

void

Defined in

libs/ts-rest/express/src/lib/types.ts:58

Functions

createExpressEndpoints

createExpressEndpoints<TRouter>(schema, router, app, options?): void

Type parameters

NameType
TRouterextends AppRouter

Parameters

NameType
schemaTRouter
routerRouterImplementation<TRouter>
appIRouter
optionsTsRestExpressOptions<TRouter>

Returns

void

Defined in

libs/ts-rest/express/src/lib/ts-rest-express.ts:294


initServer

initServer(): Object

Returns

Object

NameType
route<T, TRoute>(contract: T, route: TRoute) => TRoute
router<T, TRouter>(contract: T, router: TRouter) => TRouter

Defined in

libs/ts-rest/express/src/lib/ts-rest-express.ts:30