@ts-rest/express
Advanced tools
Comparing version 3.13.1 to 3.14.0
# @ts-rest/express | ||
## 3.14.0 | ||
## 3.13.1 | ||
@@ -4,0 +6,0 @@ |
{ | ||
"name": "@ts-rest/express", | ||
"version": "3.13.1", | ||
"version": "3.14.0", | ||
"peerDependenciesMeta": { | ||
@@ -15,3 +15,3 @@ "zod": { | ||
"zod": "3.x.x", | ||
"@ts-rest/core": "3.13.1", | ||
"@ts-rest/core": "3.14.0", | ||
"@swc/helpers": "0.4.11" | ||
@@ -18,0 +18,0 @@ }, |
/// <reference types="node" /> | ||
import { IRouter, Request } from 'express'; | ||
import { IncomingHttpHeaders } from 'http'; | ||
import { AppRoute, AppRouteMutation, AppRouteQuery, AppRouter, PathParamsWithCustomValidators, Without, ZodInferOrType } from '@ts-rest/core'; | ||
import { AppRoute, AppRouteMutation, AppRouteQuery, AppRouter, GetFieldType, PathParamsWithCustomValidators, Without, ZodInferOrType } from '@ts-rest/core'; | ||
export declare function getValue<TData, TPath extends string, TDefault = GetFieldType<TData, TPath>>(data: TData, path: TPath, defaultValue?: TDefault): GetFieldType<TData, TPath> | TDefault; | ||
export type ApiRouteResponse<T> = { | ||
@@ -6,0 +7,0 @@ [K in keyof T]: { |
@@ -9,2 +9,3 @@ "use strict"; | ||
_export(exports, { | ||
getValue: ()=>getValue, | ||
initServer: ()=>initServer, | ||
@@ -14,2 +15,8 @@ createExpressEndpoints: ()=>createExpressEndpoints | ||
const _core = require("@ts-rest/core"); | ||
function getValue(data, path, defaultValue) { | ||
const value = path.split(/[.[\]]/).filter(Boolean).reduce((value, key)=>{ | ||
return value == null ? void 0 : value[key]; | ||
}, data); | ||
return value !== undefined ? value : defaultValue; | ||
} | ||
const initServer = ()=>{ | ||
@@ -121,3 +128,3 @@ return { | ||
recursivelyApplyExpressRouter(router, [], (route, path)=>{ | ||
const routerViaPath = (0, _core.getValue)(schema, path.join('.')); | ||
const routerViaPath = getValue(schema, path.join('.')); | ||
if (!routerViaPath) { | ||
@@ -124,0 +131,0 @@ throw new Error(`[ts-rest] No router found for path ${path.join('.')}`); |
Sorry, the diff of this file is not supported yet
29380
184