@innet/server 1.6.1 → 1.6.2
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@innet/server",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.2",
|
|
4
4
|
"description": "Create server-side application with innet",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.es6.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://github.com/d8corp/innet-server",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@cantinc/utils": "^1.2.
|
|
25
|
+
"@cantinc/utils": "^1.2.7",
|
|
26
26
|
"@innet/html": "^1.0.1",
|
|
27
27
|
"@innet/jsx": "^1.1.0",
|
|
28
28
|
"@innet/switch": "^1.0.0",
|
|
@@ -13,4 +13,4 @@ export interface ValidationContext {
|
|
|
13
13
|
handleError?: (e: ValidationResponse<any>) => any;
|
|
14
14
|
}
|
|
15
15
|
export declare const validationContext: Context<ValidationContext, ValidationContext>;
|
|
16
|
-
export declare function validation<T extends object, E extends object>({ props, children }: ValidationJsxElement<T>, handler: any):
|
|
16
|
+
export declare function validation<T extends object, E extends object>({ props, children }: ValidationJsxElement<T>, handler: any): any;
|
|
@@ -14,13 +14,12 @@ function validation({ props, children }, handler) {
|
|
|
14
14
|
const data = action[resource];
|
|
15
15
|
if (!data)
|
|
16
16
|
throw Error(`cannot find ${resource} in action`);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
});
|
|
17
|
+
const result = validation$1(map, data);
|
|
18
|
+
if (result) {
|
|
19
|
+
const { handleError } = validationContext.get(handler);
|
|
20
|
+
return handleError ? innet(handleError(result), handler) : undefined;
|
|
21
|
+
}
|
|
22
|
+
return innet(children, handler);
|
|
24
23
|
};
|
|
25
24
|
if (resource === 'body' || resource === 'files') {
|
|
26
25
|
return action.parseBody().then(run);
|
|
@@ -23,13 +23,12 @@ function validation(_a, handler) {
|
|
|
23
23
|
var data = action[resource];
|
|
24
24
|
if (!data)
|
|
25
25
|
throw Error("cannot find ".concat(resource, " in action"));
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
});
|
|
26
|
+
var result = utils.validation(map, data);
|
|
27
|
+
if (result) {
|
|
28
|
+
var handleError = validationContext.get(handler).handleError;
|
|
29
|
+
return handleError ? innet__default["default"](handleError(result), handler) : undefined;
|
|
30
|
+
}
|
|
31
|
+
return innet__default["default"](children, handler);
|
|
33
32
|
};
|
|
34
33
|
if (resource === 'body' || resource === 'files') {
|
|
35
34
|
return action.parseBody().then(run);
|