fix(core): update
This commit is contained in:
parent
58637ed90e
commit
2e0c6400e8
@ -14,14 +14,14 @@
|
|||||||
"buildDocs": "tsdoc"
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@api.global/typedserver": "^3.0.44",
|
"@api.global/typedserver": "^3.0.50",
|
||||||
"@git.zone/tsbuild": "^2.1.80",
|
"@git.zone/tsbuild": "^2.1.80",
|
||||||
"@git.zone/tsbundle": "^2.0.15",
|
"@git.zone/tsbundle": "^2.0.15",
|
||||||
"@git.zone/tsrun": "^1.2.44",
|
"@git.zone/tsrun": "^1.2.44",
|
||||||
"@git.zone/tstest": "^1.0.90",
|
"@git.zone/tstest": "^1.0.90",
|
||||||
"@push.rocks/smartenv": "^5.0.12",
|
"@push.rocks/smartenv": "^5.0.12",
|
||||||
"@push.rocks/tapbundle": "^5.0.23",
|
"@push.rocks/tapbundle": "^5.0.23",
|
||||||
"@types/node": "^20.12.12"
|
"@types/node": "^20.12.13"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@api.global/typedrequest-interfaces": "^3.0.19",
|
"@api.global/typedrequest-interfaces": "^3.0.19",
|
||||||
@ -29,10 +29,10 @@
|
|||||||
"@push.rocks/lik": "^6.0.15",
|
"@push.rocks/lik": "^6.0.15",
|
||||||
"@push.rocks/smartbuffer": "^3.0.4",
|
"@push.rocks/smartbuffer": "^3.0.4",
|
||||||
"@push.rocks/smartdelay": "^3.0.5",
|
"@push.rocks/smartdelay": "^3.0.5",
|
||||||
"@push.rocks/smartguard": "^3.0.1",
|
"@push.rocks/smartguard": "^3.0.2",
|
||||||
"@push.rocks/smartpromise": "^4.0.3",
|
"@push.rocks/smartpromise": "^4.0.3",
|
||||||
"@push.rocks/webrequest": "^3.0.37",
|
"@push.rocks/webrequest": "^3.0.37",
|
||||||
"@push.rocks/webstream": "^1.0.8"
|
"@push.rocks/webstream": "^1.0.10"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
|
424
pnpm-lock.yaml
424
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@api.global/typedrequest',
|
name: '@api.global/typedrequest',
|
||||||
version: '3.0.26',
|
version: '3.0.27',
|
||||||
description: 'A TypeScript library for making typed requests towards APIs, including facilities for handling requests, routing, and virtual stream handling.'
|
description: 'A TypeScript library for making typed requests towards APIs, including facilities for handling requests, routing, and virtual stream handling.'
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
import * as plugins from './plugins.js';
|
import * as plugins from './plugins.js';
|
||||||
import { TypedResponseError } from './classes.typedresponseerror.js';
|
import { TypedResponseError } from './classes.typedresponseerror.js';
|
||||||
|
import { TypedTools } from './classes.typedtools.js';
|
||||||
|
|
||||||
export type THandlerFunction<T extends plugins.typedRequestInterfaces.ITypedRequest> = (
|
export type THandlerFunction<T extends plugins.typedRequestInterfaces.ITypedRequest> = (
|
||||||
requestArg: T['request']
|
requestArg: T['request'],
|
||||||
|
typedToolsArg?: any
|
||||||
) => Promise<T['response']>;
|
) => Promise<T['response']>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,7 +30,8 @@ export class TypedHandler<T extends plugins.typedRequestInterfaces.ITypedRequest
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
let typedResponseError: TypedResponseError;
|
let typedResponseError: TypedResponseError;
|
||||||
const response = await this.handlerFunction(typedRequestArg.request).catch((e) => {
|
const typedtoolsInstance = new TypedTools();
|
||||||
|
const response = await this.handlerFunction(typedRequestArg.request, typedtoolsInstance).catch((e) => {
|
||||||
if (e instanceof TypedResponseError) {
|
if (e instanceof TypedResponseError) {
|
||||||
typedResponseError = e;
|
typedResponseError = e;
|
||||||
} else {
|
} else {
|
||||||
|
13
ts/classes.typedtools.ts
Normal file
13
ts/classes.typedtools.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { TypedResponseError } from './classes.typedresponseerror.js';
|
||||||
|
import * as plugins from './plugins.js';
|
||||||
|
|
||||||
|
export class TypedTools {
|
||||||
|
public async passGuards<T = any>(guardsArg: plugins.smartguard.Guard<T>[], dataArg: T) {
|
||||||
|
const guardSet = new plugins.smartguard.GuardSet<T>(guardsArg);
|
||||||
|
const guardResult = await guardSet.allGuardsPass(dataArg);
|
||||||
|
if (!guardResult) {
|
||||||
|
const failedHint = await guardSet.getFailedHint(dataArg);
|
||||||
|
throw new TypedResponseError(`guard failed: ${failedHint}`, { failedHint });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user