@ts-rest/nest
Advanced tools
Comparing version 3.48.1 to 3.49.0-beta.1
# @ts-rest/nest | ||
## 3.49.0-beta.1 | ||
## 3.49.0-beta.0 | ||
## 3.48.1 | ||
@@ -4,0 +8,0 @@ |
@@ -14,2 +14,6 @@ 'use strict'; | ||
/** | ||
* @deprecated Use `nestControllerContract`, `NestControllerInterface`, `NestRequestShapes`, and `NestResponseShapes` instead | ||
* @see {@link https://ts-rest.com/docs/nest|ts-rest docs} for more info. | ||
*/ | ||
const initNestServer = (router) => { | ||
@@ -23,3 +27,8 @@ return { | ||
}; | ||
/** | ||
* Returns the contract containing only non-nested routes required by a NestJS controller | ||
*/ | ||
const nestControllerContract = (router) => { | ||
// it's not worth actually filtering the contract at runtime | ||
// the typing will already ensure that nested routes cannot be used at compile time | ||
return router; | ||
@@ -106,2 +115,3 @@ }; | ||
if (!appRoute) { | ||
// this will respond with a 500 error without revealing this error message in the response body | ||
throw new Error('Make sure your route is decorated with @TsRest()'); | ||
@@ -150,2 +160,7 @@ } | ||
/** | ||
* As a class decorator, you can configure ts-rest options. As a method decorator, you can assign the route and also configure options | ||
* @param appRouteOrOptions For a method decorator, this is the route. For a class decorator, this is the options | ||
* @param options For a method decorator, this is the options | ||
*/ | ||
const TsRest = (appRouteOrOptions, options) => { | ||
@@ -181,2 +196,5 @@ const decorators = []; | ||
}; | ||
/** | ||
* @deprecated Use TsRest decorator instead | ||
*/ | ||
const Api = (appRoute) => { | ||
@@ -193,2 +211,3 @@ return TsRest(appRoute); | ||
if (!appRoute) { | ||
// this will respond with a 500 error without revealing this error message in the response body | ||
throw new Error('Make sure your route is decorated with @TsRest()'); | ||
@@ -237,5 +256,11 @@ } | ||
], TsRestValidatorPipe); | ||
/** | ||
* Parameter decorator used to parse, validate and return the typed request object | ||
*/ | ||
const TsRestRequest = () => common.createParamDecorator((_, ctx) => { | ||
return ctx; | ||
})(TsRestValidatorPipe); | ||
/** | ||
* @deprecated Use `TsRestRequest` instead | ||
*/ | ||
const ApiDecorator = TsRestRequest; | ||
@@ -305,3 +330,12 @@ | ||
}; | ||
/** | ||
* | ||
* @param contract - The contract or route to implement | ||
* @param implementation - Implementation of the route or entire contract as an object | ||
* @returns | ||
*/ | ||
const tsRestHandler = (contract, implementation) => implementation; | ||
/** | ||
* Error you can throw to return a response from a handler | ||
*/ | ||
class TsRestException extends common.HttpException { | ||
@@ -313,4 +347,11 @@ constructor(route, response, options) { | ||
const doesUrlMatchContractPath = ( | ||
contractPath, | ||
/** | ||
* @example '/posts/:id' | ||
*/ | ||
contractPath, | ||
/** | ||
* @example '/posts/1' | ||
*/ | ||
url) => { | ||
// strip trailing slash | ||
if (contractPath !== '/' && contractPath.endsWith('/')) { | ||
@@ -317,0 +358,0 @@ contractPath = contractPath.slice(0, -1); |
@@ -10,2 +10,6 @@ import { ConfigurableModuleBuilder, Module, Injectable, Optional, Inject, SetMetadata, UseInterceptors, applyDecorators, Put, Patch, Post, Get, Delete, createParamDecorator, BadRequestException, InternalServerErrorException, All, HttpException, NotFoundException } from '@nestjs/common'; | ||
/** | ||
* @deprecated Use `nestControllerContract`, `NestControllerInterface`, `NestRequestShapes`, and `NestResponseShapes` instead | ||
* @see {@link https://ts-rest.com/docs/nest|ts-rest docs} for more info. | ||
*/ | ||
const initNestServer = (router) => { | ||
@@ -19,3 +23,8 @@ return { | ||
}; | ||
/** | ||
* Returns the contract containing only non-nested routes required by a NestJS controller | ||
*/ | ||
const nestControllerContract = (router) => { | ||
// it's not worth actually filtering the contract at runtime | ||
// the typing will already ensure that nested routes cannot be used at compile time | ||
return router; | ||
@@ -102,2 +111,3 @@ }; | ||
if (!appRoute) { | ||
// this will respond with a 500 error without revealing this error message in the response body | ||
throw new Error('Make sure your route is decorated with @TsRest()'); | ||
@@ -146,2 +156,7 @@ } | ||
/** | ||
* As a class decorator, you can configure ts-rest options. As a method decorator, you can assign the route and also configure options | ||
* @param appRouteOrOptions For a method decorator, this is the route. For a class decorator, this is the options | ||
* @param options For a method decorator, this is the options | ||
*/ | ||
const TsRest = (appRouteOrOptions, options) => { | ||
@@ -177,2 +192,5 @@ const decorators = []; | ||
}; | ||
/** | ||
* @deprecated Use TsRest decorator instead | ||
*/ | ||
const Api = (appRoute) => { | ||
@@ -189,2 +207,3 @@ return TsRest(appRoute); | ||
if (!appRoute) { | ||
// this will respond with a 500 error without revealing this error message in the response body | ||
throw new Error('Make sure your route is decorated with @TsRest()'); | ||
@@ -233,5 +252,11 @@ } | ||
], TsRestValidatorPipe); | ||
/** | ||
* Parameter decorator used to parse, validate and return the typed request object | ||
*/ | ||
const TsRestRequest = () => createParamDecorator((_, ctx) => { | ||
return ctx; | ||
})(TsRestValidatorPipe); | ||
/** | ||
* @deprecated Use `TsRestRequest` instead | ||
*/ | ||
const ApiDecorator = TsRestRequest; | ||
@@ -301,3 +326,12 @@ | ||
}; | ||
/** | ||
* | ||
* @param contract - The contract or route to implement | ||
* @param implementation - Implementation of the route or entire contract as an object | ||
* @returns | ||
*/ | ||
const tsRestHandler = (contract, implementation) => implementation; | ||
/** | ||
* Error you can throw to return a response from a handler | ||
*/ | ||
class TsRestException extends HttpException { | ||
@@ -309,4 +343,11 @@ constructor(route, response, options) { | ||
const doesUrlMatchContractPath = ( | ||
contractPath, | ||
/** | ||
* @example '/posts/:id' | ||
*/ | ||
contractPath, | ||
/** | ||
* @example '/posts/1' | ||
*/ | ||
url) => { | ||
// strip trailing slash | ||
if (contractPath !== '/' && contractPath.endsWith('/')) { | ||
@@ -313,0 +354,0 @@ contractPath = contractPath.slice(0, -1); |
{ | ||
"name": "@ts-rest/nest", | ||
"version": "3.48.1", | ||
"version": "3.49.0-beta.1", | ||
"private": false, | ||
"description": "Nest server integration for @ts-rest", | ||
"license": "MIT", | ||
"keywords": [ | ||
@@ -16,3 +16,2 @@ "rpc", | ||
], | ||
"private": false, | ||
"repository": { | ||
@@ -23,5 +22,22 @@ "type": "git", | ||
}, | ||
"license": "MIT", | ||
"exports": { | ||
"./package.json": "./package.json", | ||
".": { | ||
"module": "./index.esm.js", | ||
"import": "./index.cjs.mjs", | ||
"default": "./index.cjs.js" | ||
} | ||
}, | ||
"main": "./index.cjs.js", | ||
"module": "./index.esm.js", | ||
"devDependencies": { | ||
"@nestjs/platform-express": "^9.0.0 || ^10.0.0", | ||
"@nestjs/platform-fastify": "^9.0.0 || ^10.0.0", | ||
"fastify": "^4.0.0" | ||
}, | ||
"peerDependencies": { | ||
"@nestjs/common": "^9.0.0 || ^10.0.0", | ||
"@nestjs/core": "^9.0.0 || ^10.0.0", | ||
"@ts-rest/core": "~3.49.0-beta.0", | ||
"rxjs": "^7.1.0", | ||
@@ -34,18 +50,3 @@ "zod": "^3.22.3" | ||
} | ||
}, | ||
"devDependencies": { | ||
"@nestjs/platform-express": "^9.0.0 || ^10.0.0", | ||
"@nestjs/platform-fastify": "^9.0.0 || ^10.0.0", | ||
"fastify": "^4.0.0" | ||
}, | ||
"exports": { | ||
"./package.json": "./package.json", | ||
".": { | ||
"module": "./index.esm.js", | ||
"import": "./index.cjs.mjs", | ||
"default": "./index.cjs.js" | ||
} | ||
}, | ||
"module": "./index.esm.js", | ||
"main": "./index.cjs.js" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
100184
1800
5
2