@ts-rest/nest
Advanced tools
Comparing version 2.1.0 to 3.0.0
# @ts-rest/nest | ||
## 3.0.0 | ||
### Major Changes | ||
- 895112a: Migrate paths to a string rather than function | ||
## 2.1.0 | ||
@@ -4,0 +10,0 @@ |
{ | ||
"name": "@ts-rest/nest", | ||
"version": "2.1.0", | ||
"version": "3.0.0", | ||
"description": "Nest server integration for @ts-rest", | ||
@@ -28,3 +28,3 @@ "type": "commonjs", | ||
"@nestjs/common": "^9.0.11", | ||
"@ts-rest/core": "2.1.0", | ||
"@ts-rest/core": "3.0.0", | ||
"zod": "^3.18.0", | ||
@@ -31,0 +31,0 @@ "rxjs": "^7.0.0", |
import { CallHandler, ExecutionContext, NestInterceptor } from '@nestjs/common'; | ||
import { AppRoute, AppRouteMutation, Without } from '@ts-rest/core'; | ||
import { AppRoute, AppRouteMutation, PathParams, Without } from '@ts-rest/core'; | ||
import { Observable } from 'rxjs'; | ||
import { z, ZodTypeAny } from 'zod'; | ||
export declare type ApiDecoratorShape<TRoute extends AppRoute> = Without<{ | ||
params: Parameters<TRoute['path']>[0]; | ||
params: PathParams<TRoute>; | ||
body: TRoute extends AppRouteMutation ? TRoute['body'] extends ZodTypeAny ? z.infer<TRoute['body']> : TRoute['body'] : never; | ||
@@ -8,0 +8,0 @@ query: TRoute['query'] extends ZodTypeAny ? z.infer<TRoute['query']> : TRoute['query']; |
@@ -31,3 +31,3 @@ "use strict"; | ||
const checkBodySchema = (body, appRoute)=>{ | ||
if (appRoute.__tsType === 'AppRouteMutation' && appRoute.body) { | ||
if (appRoute.method !== 'GET' && appRoute.body) { | ||
if (isZodObject(appRoute.body)) { | ||
@@ -92,2 +92,3 @@ const result = appRoute.body.safeParse(body); | ||
query: queryResult.body, | ||
// @ts-expect-error because the decorator shape is any | ||
params: pathParams, | ||
@@ -98,14 +99,13 @@ body: bodyResult.body | ||
const getMethodDecorator = (appRoute)=>{ | ||
const path = (0, _core.getAppRoutePathRoute)(appRoute); | ||
switch(appRoute.method){ | ||
case 'DELETE': | ||
return (0, _common.Delete)(path); | ||
return (0, _common.Delete)(appRoute.path); | ||
case 'GET': | ||
return (0, _common.Get)(path); | ||
return (0, _common.Get)(appRoute.path); | ||
case 'POST': | ||
return (0, _common.Post)(path); | ||
return (0, _common.Post)(appRoute.path); | ||
case 'PATCH': | ||
return (0, _common.Patch)(path); | ||
return (0, _common.Patch)(appRoute.path); | ||
case 'PUT': | ||
return (0, _common.Put)(path); | ||
return (0, _common.Put)(appRoute.path); | ||
} | ||
@@ -112,0 +112,0 @@ }; |
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
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
20682