@tsed/platform-params
Advanced tools
Comparing version 8.2.0 to 8.3.0
@@ -49,12 +49,13 @@ import { injectable, injector, ProviderScope } from "@tsed/di"; | ||
} | ||
getArg(scope, pipes, param) { | ||
return pipes.reduce(async (value, pipe) => { | ||
value = await value; | ||
try { | ||
return await pipe.transform(value, param); | ||
async getArg(scope, pipes, param) { | ||
try { | ||
let value = scope; | ||
for await (const pipe of pipes) { | ||
value = await pipe.transform(value, param); | ||
} | ||
catch (er) { | ||
throw ParamValidationError.from(param, er); | ||
} | ||
}, scope); | ||
return value; | ||
} | ||
catch (er) { | ||
throw ParamValidationError.from(param, er); | ||
} | ||
} | ||
@@ -61,0 +62,0 @@ } |
@@ -23,3 +23,3 @@ import { DIContext } from "@tsed/di"; | ||
compile<Context extends DIContext = DIContext>(entity: JsonMethodStore): PlatformParamsCallback<Context>; | ||
getArg<Context extends DIContext = DIContext>(scope: PlatformParamsScope, pipes: PipeMethods[], param: JsonParameterStore): Promise<any>; | ||
getArg<Context extends DIContext = DIContext>(scope: PlatformParamsScope<Context>, pipes: PipeMethods[], param: JsonParameterStore): Promise<any>; | ||
} |
@@ -5,3 +5,3 @@ { | ||
"type": "module", | ||
"version": "8.2.0", | ||
"version": "8.3.0", | ||
"source": "./src/index.ts", | ||
@@ -30,9 +30,9 @@ "main": "./lib/esm/index.js", | ||
"devDependencies": { | ||
"@tsed/barrels": "8.2.0", | ||
"@tsed/core": "8.2.0", | ||
"@tsed/di": "8.2.0", | ||
"@tsed/exceptions": "8.2.0", | ||
"@tsed/json-mapper": "8.2.0", | ||
"@tsed/schema": "8.2.0", | ||
"@tsed/typescript": "8.2.0", | ||
"@tsed/barrels": "8.3.0", | ||
"@tsed/core": "8.3.0", | ||
"@tsed/di": "8.3.0", | ||
"@tsed/exceptions": "8.3.0", | ||
"@tsed/json-mapper": "8.3.0", | ||
"@tsed/schema": "8.3.0", | ||
"@tsed/typescript": "8.3.0", | ||
"eslint": "9.12.0", | ||
@@ -43,7 +43,7 @@ "typescript": "5.4.5", | ||
"peerDependencies": { | ||
"@tsed/core": "8.2.0", | ||
"@tsed/di": "8.2.0", | ||
"@tsed/exceptions": "8.2.0", | ||
"@tsed/json-mapper": "8.2.0", | ||
"@tsed/schema": "8.2.0" | ||
"@tsed/core": "8.3.0", | ||
"@tsed/di": "8.3.0", | ||
"@tsed/exceptions": "8.3.0", | ||
"@tsed/json-mapper": "8.3.0", | ||
"@tsed/schema": "8.3.0" | ||
}, | ||
@@ -50,0 +50,0 @@ "peerDependenciesMeta": { |
<p style="text-align: center" align="center"> | ||
<a href="https://tsed.io" target="_blank"><img src="https://tsed.io/tsed-og.png" width="200" alt="Ts.ED logo"/></a> | ||
<a href="https://tsed.io" target="_blank"><img src="https://tsed.devtsed-og.png" width="200" alt="Ts.ED logo"/></a> | ||
</p> | ||
@@ -19,5 +19,5 @@ | ||
<div align="center"> | ||
<a href="https://tsed.io/">Website</a> | ||
<a href="https://tsed.dev">Website</a> | ||
<span> • </span> | ||
<a href="https://tsed.io/getting-started/">Getting started</a> | ||
<a href="https://tsed.dev/getting-started/">Getting started</a> | ||
<span> • </span> | ||
@@ -31,3 +31,3 @@ <a href="https://slack.tsed.io">Slack</a> | ||
A package of Ts.ED framework. See website: https://tsed.io/ | ||
A package of Ts.ED framework. See website: https://tsed.dev | ||
@@ -42,3 +42,3 @@ # Installation | ||
Please read [contributing guidelines here](https://tsed.io/contributing.html). | ||
Please read [contributing guidelines here](https://tsed.devcontributing.html). | ||
@@ -45,0 +45,0 @@ <a href="https://github.com/tsedio/tsed/graphs/contributors"><img src="https://opencollective.com/tsed/contributors.svg?width=890" /></a> |
@@ -67,4 +67,4 @@ import {DIContext, Inject, Injectable, injectable, injector, InjectorService, ProviderScope, TokenProvider} from "@tsed/di"; | ||
return (scope) => { | ||
const promises = argsPipes.map(({param, pipes}) => this.getArg(scope, pipes, param)); | ||
return (scope: PlatformParamsScope<Context>) => { | ||
const promises = argsPipes.map(({param, pipes}) => this.getArg<Context>(scope, pipes, param)); | ||
return Promise.all(promises); | ||
@@ -74,12 +74,18 @@ }; | ||
getArg<Context extends DIContext = DIContext>(scope: PlatformParamsScope, pipes: PipeMethods[], param: JsonParameterStore): Promise<any> { | ||
return pipes.reduce(async (value: any | Promise<any>, pipe) => { | ||
value = await value; | ||
async getArg<Context extends DIContext = DIContext>( | ||
scope: PlatformParamsScope<Context>, | ||
pipes: PipeMethods[], | ||
param: JsonParameterStore | ||
): Promise<any> { | ||
try { | ||
let value = scope; | ||
try { | ||
return await pipe.transform(value, param); | ||
} catch (er) { | ||
throw ParamValidationError.from(param, er); | ||
for await (const pipe of pipes) { | ||
value = await pipe.transform(value, param); | ||
} | ||
}, scope); | ||
return value; | ||
} catch (er) { | ||
throw ParamValidationError.from(param, er); | ||
} | ||
} | ||
@@ -86,0 +92,0 @@ } |
Sorry, the diff of this file is not supported yet
164556
4255