@modern-js/bff-core 1.1.3-beta.0 → 1.2.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/js/modern/api.js
CHANGED
|
@@ -23,6 +23,7 @@ export function Api(...args) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
const validateHandlers = operators.filter(operator => operator.validate).map(operator => operator.validate);
|
|
26
|
+
const pipeHandlers = operators.filter(operator => operator.pipe).map(operator => operator.validate);
|
|
26
27
|
|
|
27
28
|
async function runner(inputs) {
|
|
28
29
|
const executeHelper = {
|
|
@@ -32,8 +33,10 @@ export function Api(...args) {
|
|
|
32
33
|
return inputs;
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
};
|
|
36
|
-
|
|
36
|
+
}; // 肯定是要在 stack 后面加函数
|
|
37
|
+
// 怎么终止中间件继续执行呢
|
|
38
|
+
|
|
39
|
+
const stack = [...validateHandlers, ...pipeHandlers];
|
|
37
40
|
stack.push(async (helper, next) => {
|
|
38
41
|
const res = await handler(inputs);
|
|
39
42
|
helper.result = res;
|
package/dist/js/node/api.js
CHANGED
|
@@ -35,6 +35,7 @@ function Api(...args) {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
const validateHandlers = operators.filter(operator => operator.validate).map(operator => operator.validate);
|
|
38
|
+
const pipeHandlers = operators.filter(operator => operator.pipe).map(operator => operator.validate);
|
|
38
39
|
|
|
39
40
|
async function runner(inputs) {
|
|
40
41
|
const executeHelper = {
|
|
@@ -44,8 +45,10 @@ function Api(...args) {
|
|
|
44
45
|
return inputs;
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
};
|
|
48
|
-
|
|
48
|
+
}; // 肯定是要在 stack 后面加函数
|
|
49
|
+
// 怎么终止中间件继续执行呢
|
|
50
|
+
|
|
51
|
+
const stack = [...validateHandlers, ...pipeHandlers];
|
|
49
52
|
stack.push(async (helper, next) => {
|
|
50
53
|
const res = await handler(inputs);
|
|
51
54
|
helper.result = res;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export declare enum HttpMethod {
|
|
|
31
31
|
Head = "HEAD",
|
|
32
32
|
}
|
|
33
33
|
export declare type InputSchemaMeata = Extract<HttpMetadata, HttpMetadata.Data | HttpMetadata.Query | HttpMetadata.Headers | HttpMetadata.Params>;
|
|
34
|
-
export declare type
|
|
34
|
+
export declare type ExecuteFunc = (helper: ExecuteHelper, next: () => Promise<any>) => Promise<any>;
|
|
35
35
|
export declare type ExecuteHelper = {
|
|
36
36
|
result?: any;
|
|
37
37
|
readonly inputs: any;
|
|
@@ -44,7 +44,8 @@ export declare type Operator<Input> = {
|
|
|
44
44
|
name: string;
|
|
45
45
|
inputType?: Input;
|
|
46
46
|
metadata?: (helper: MetadataHelper) => void;
|
|
47
|
-
validate?:
|
|
47
|
+
validate?: ExecuteFunc;
|
|
48
|
+
pipe?: ExecuteFunc;
|
|
48
49
|
};
|
|
49
50
|
export declare type MaybeAsync<T> = Promise<T> | T;
|
|
50
51
|
export declare type ApiRunner<Input extends object | void | unknown, Output extends MaybeAsync<any>> = (...args: Input extends void ? never : [input: Input]) => Output;
|
|
@@ -52,5 +53,4 @@ export declare type NonNullable<T> = Exclude<T, null | undefined>;
|
|
|
52
53
|
export declare type ExtractInputType<T> = { [key in keyof T]: T[key] extends Operator<any> ? NonNullable<T[key]['inputType']> : void };
|
|
53
54
|
export declare type ArrayToObject<T, R = {}> = T extends [infer First, ...infer Rest] ? First extends PromiseLike<infer PromiseValue> ? PromiseValue : First extends object ? Merge<First, ArrayToObject<Rest, R>> : ArrayToObject<Rest, R> : R;
|
|
54
55
|
export declare type AsyncFunction = (...args: any[]) => Promise<any>;
|
|
55
|
-
export declare const httpMethods: HttpMethod[];
|
|
56
|
-
export declare type ApiMiddleware = (next: () => any | Promise<any>) => any;
|
|
56
|
+
export declare const httpMethods: HttpMethod[];
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.1
|
|
14
|
+
"version": "1.2.1-beta.0",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@babel/runtime": "^7.18.0",
|
|
28
|
-
"@modern-js/bff-runtime": "^1.
|
|
29
|
-
"@modern-js/utils": "^1.
|
|
28
|
+
"@modern-js/bff-runtime": "^1.4.0",
|
|
29
|
+
"@modern-js/utils": "^1.8.0",
|
|
30
30
|
"esbuild": "^0.14.38",
|
|
31
31
|
"esbuild-register": "^3.3.3",
|
|
32
32
|
"koa-compose": "^4.1.0",
|