@ts-rest/nest
Advanced tools
Comparing version 1.3.0 to 2.0.0
# @ts-rest/nest | ||
## 2.0.0 | ||
### Major Changes | ||
- 223c7cc: Change contract to support multiple responses, for different statuses | ||
### Patch Changes | ||
- 9a42657: Add error handling support to express | ||
## 1.3.0 | ||
@@ -4,0 +14,0 @@ |
{ | ||
"name": "@ts-rest/nest", | ||
"version": "1.3.0", | ||
"version": "2.0.0", | ||
"description": "Nest server integration for @ts-rest", | ||
@@ -28,4 +28,4 @@ "type": "commonjs", | ||
"@nestjs/common": "^9.0.8", | ||
"@ts-rest/core": "1.3.0", | ||
"zod": "^3.17.10", | ||
"@ts-rest/core": "2.0.0", | ||
"zod": "^3.18.0", | ||
"rxjs": "^7.0.0", | ||
@@ -32,0 +32,0 @@ "@swc/helpers": "~0.4.3" |
@@ -17,2 +17,3 @@ "use strict"; | ||
const _core = require("@ts-rest/core"); | ||
const _rxjs = require("rxjs"); | ||
const getQueryParams = (url)=>{ | ||
@@ -50,3 +51,3 @@ const searchParams = new URLSearchParams(url.split('?')[1]); | ||
const checkBodySchema = (body, appRoute)=>{ | ||
if (appRoute.__type === 'AppRouteMutation' && appRoute.body) { | ||
if (appRoute.__tsType === 'AppRouteMutation' && appRoute.body) { | ||
if (isZodObject(appRoute.body)) { | ||
@@ -135,3 +136,8 @@ const result = appRoute.body.safeParse(body); | ||
req.appRoute = this.appRoute; | ||
return next.handle(); | ||
return next.handle().pipe((0, _rxjs.map)((value)=>{ | ||
if (typeof value === 'object' && typeof value.status === 'number' && value.data !== undefined) { | ||
throw new _common.HttpException(value == null ? void 0 : value.data, value.status); | ||
} | ||
return value; | ||
})); | ||
} | ||
@@ -138,0 +144,0 @@ constructor(appRoute){ |
@@ -1,4 +0,4 @@ | ||
import { AppRoute, AppRouter, Without, ZodInferOrType } from '@ts-rest/core'; | ||
import { AppRoute, AppRouter, ApiRouteResponse, Without } from '@ts-rest/core'; | ||
import { ApiDecoratorShape } from './api.decorator'; | ||
declare type AppRouterMethodShape<T extends AppRoute> = (...args: any[]) => Promise<ZodInferOrType<T['response']>>; | ||
declare type AppRouterMethodShape<T extends AppRoute> = (...args: any[]) => Promise<ApiRouteResponse<T['responses']>>; | ||
declare type AppRouterControllerShape<T extends AppRouter> = { | ||
@@ -5,0 +5,0 @@ [K in keyof T]: T[K] extends AppRouter ? undefined : T[K] extends AppRoute ? AppRouterMethodShape<T[K]> : never; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Unpublished package
Supply chain riskPackage version was not found on the registry. It may exist on a different registry and need to be configured to pull from that registry.
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
22775
207
1