Skip to main content

Module: @ts-rest/nest

Classes

Type Aliases

NestControllerContract

Ƭ NestControllerContract<T>: Pick<T, { [K in keyof T]-?: T[K] extends AppRoute ? K : never }[keyof T]>

Type parameters

NameType
Textends AppRouter

Defined in

libs/ts-rest/nest/src/lib/ts-rest-nest.ts:49


NestControllerInterface

Ƭ NestControllerInterface<T>: AppRouterControllerShape<T>

Type parameters

NameType
Textends AppRouter

Defined in

libs/ts-rest/nest/src/lib/ts-rest-nest.ts:55


NestRequestShapes

Ƭ NestRequestShapes<T>: AppRouterRequestShapes<T>

Type parameters

NameType
Textends AppRouter

Defined in

libs/ts-rest/nest/src/lib/ts-rest-nest.ts:57


NestResponseShapes

Ƭ NestResponseShapes<T>: AppRouterResponseShapes<T>

Type parameters

NameType
Textends AppRouter

Defined in

libs/ts-rest/nest/src/lib/ts-rest-nest.ts:58


TsRestOptions

Ƭ TsRestOptions: Object

Type declaration

NameType
jsonQuery?boolean
validateRequestBody?boolean
validateRequestHeaders?boolean
validateRequestQuery?boolean
validateResponses?boolean

Defined in

libs/ts-rest/nest/src/lib/ts-rest.decorator.ts:22


TsRestRequestShape

Ƭ TsRestRequestShape<TRoute>: ServerInferRequest<TRoute, Request["headers"]>

Type parameters

NameType
TRouteextends AppRoute

Defined in

libs/ts-rest/nest/src/lib/ts-rest-request.decorator.ts:24

Variables

JsonQuerySymbol

Const JsonQuerySymbol: typeof JsonQuerySymbol

Defined in

libs/ts-rest/nest/src/lib/constants.ts:2


TsRestAppRouteMetadataKey

Const TsRestAppRouteMetadataKey: typeof TsRestAppRouteMetadataKey

Defined in

libs/ts-rest/nest/src/lib/constants.ts:1


ValidateRequestBodySymbol

Const ValidateRequestBodySymbol: typeof ValidateRequestBodySymbol

Defined in

libs/ts-rest/nest/src/lib/constants.ts:10


ValidateRequestHeadersSymbol

Const ValidateRequestHeadersSymbol: typeof ValidateRequestHeadersSymbol

Defined in

libs/ts-rest/nest/src/lib/constants.ts:4


ValidateRequestQuerySymbol

Const ValidateRequestQuerySymbol: typeof ValidateRequestQuerySymbol

Defined in

libs/ts-rest/nest/src/lib/constants.ts:7


ValidateResponsesSymbol

Const ValidateResponsesSymbol: typeof ValidateResponsesSymbol

Defined in

libs/ts-rest/nest/src/lib/constants.ts:3

Functions

Api

Api(appRoute): MethodDecorator

Parameters

NameType
appRouteAppRoute

Returns

MethodDecorator

Deprecated

Use TsRest decorator instead

Defined in

libs/ts-rest/nest/src/lib/ts-rest.decorator.ts:126


ApiDecorator

ApiDecorator(...dataOrPipes): ParameterDecorator

Parameters

NameType
...dataOrPipesunknown[]

Returns

ParameterDecorator

Deprecated

Use TsRestRequest instead

Defined in

node_modules/.pnpm/@nestjs+common@10.1.2_reflect-metadata@0.1.13_rxjs@7.8.1/node_modules/@nestjs/common/decorators/http/create-route-param-metadata.decorator.d.ts:12


JsonQuery

JsonQuery(jsonQuery?): CustomDecorator<typeof JsonQuerySymbol>

Enable JSON query mode for a controller or a single route

Parameters

NameTypeDefault value
jsonQuerybooleantrue

Returns

CustomDecorator<typeof JsonQuerySymbol>

Defined in

libs/ts-rest/nest/src/lib/json-query.decorator.ts:7


TsRest

TsRest(appRoute, options?): MethodDecorator

As a class decorator, you can configure ts-rest options. As a method decorator, you can assign the route and also configure options

Parameters

NameTypeDescription
appRouteAppRoute-
options?TsRestOptionsFor a method decorator, this is the options

Returns

MethodDecorator

Defined in

libs/ts-rest/nest/src/lib/ts-rest.decorator.ts:31

TsRest(options): ClassDecorator

As a class decorator, you can configure ts-rest options. As a method decorator, you can assign the route and also configure options

Parameters

NameTypeDescription
optionsTsRestOptionsFor a method decorator, this is the options

Returns

ClassDecorator

Defined in

libs/ts-rest/nest/src/lib/ts-rest.decorator.ts:32


TsRestHandler

TsRestHandler(appRouterOrRoute, options?): MethodDecorator

Parameters

NameType
appRouterOrRouteAppRoute | AppRouter
optionsTsRestOptions

Returns

MethodDecorator

Defined in

libs/ts-rest/nest/src/lib/ts-rest-nest-handler.ts:70


TsRestRequest

TsRestRequest(...dataOrPipes): ParameterDecorator

Parameter decorator used to parse, validate and return the typed request object

Parameters

NameType
...dataOrPipesunknown[]

Returns

ParameterDecorator

Defined in

node_modules/.pnpm/@nestjs+common@10.1.2_reflect-metadata@0.1.13_rxjs@7.8.1/node_modules/@nestjs/common/decorators/http/create-route-param-metadata.decorator.d.ts:12


doesUrlMatchContractPath

doesUrlMatchContractPath(contractPath, url): boolean

Parameters

NameTypeDescription
contractPathstringExample ts '/posts/:id'
urlstringExample ts '/posts/1'

Returns

boolean

Defined in

libs/ts-rest/nest/src/lib/ts-rest-nest-handler.ts:173


initNestServer

initNestServer<T>(router): Object

Type parameters

NameType
Textends AppRouter

Parameters

NameType
routerT

Returns

Object

NameType
controllerShapeAppRouterControllerShape<T>
responseShapesAppRouterResponseShapes<T>
routeT
routeShapesAppRouterRequestShapes<T>

Deprecated

Use nestControllerContract, NestControllerInterface, NestRequestShapes, and NestResponseShapes instead

See

docs for more info.

Defined in

libs/ts-rest/nest/src/lib/ts-rest-nest.ts:40


nestControllerContract

nestControllerContract<T>(router): NestControllerContract<T>

Returns the contract containing only non-nested routes required by a NestJS controller

Type parameters

NameType
Textends AppRouter

Parameters

NameType
routerT

Returns

NestControllerContract<T>

Defined in

libs/ts-rest/nest/src/lib/ts-rest-nest.ts:64


tsRestHandler

tsRestHandler<T>(contract, implementation): NestHandlerImplementation<T>

Type parameters

NameType
Textends AppRoute | AppRouter

Parameters

NameTypeDescription
contractTThe contract or route to implement
implementationNestHandlerImplementation<T>Implementation of the route or entire contract as an object

Returns

NestHandlerImplementation<T>

Defined in

libs/ts-rest/nest/src/lib/ts-rest-nest-handler.ts:159