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-options.ts:4


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​

TsRestAppRouteMetadataKey​

• Const TsRestAppRouteMetadataKey: typeof TsRestAppRouteMetadataKey

Defined in​

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


TsRestOptionsMetadataKey​

• Const TsRestOptionsMetadataKey: typeof TsRestOptionsMetadataKey

Defined in​

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

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:73


ApiDecorator​

â–¸ ApiDecorator(): ParameterDecorator

Returns​

ParameterDecorator

Deprecated

Use TsRestRequest instead

Defined in​

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


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:20

â–¸ 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:21


TsRestHandler​

â–¸ TsRestHandler(appRouterOrRoute, options?): MethodDecorator

Parameters​

NameType
appRouterOrRouteAppRoute | AppRouter
options?TsRestOptions

Returns​

MethodDecorator

Defined in​

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


TsRestRequest​

â–¸ TsRestRequest(): ParameterDecorator

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

Returns​

ParameterDecorator

Defined in​

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


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:165


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:147