@modern-js/plugin-express 2.11.0 → 2.12.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/CHANGELOG.md +11 -0
- package/dist/cjs/plugin.js +2 -2
- package/dist/cjs/utils.js +11 -11
- package/dist/esm-node/plugin.js +2 -2
- package/dist/esm-node/utils.js +11 -11
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @modern-js/plugin-express
|
|
2
2
|
|
|
3
|
+
## 2.12.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [c2ca6c8]
|
|
8
|
+
- Updated dependencies [6d86e34]
|
|
9
|
+
- @modern-js/utils@2.12.0
|
|
10
|
+
- @modern-js/bff-core@2.12.0
|
|
11
|
+
- @modern-js/bff-runtime@2.12.0
|
|
12
|
+
- @modern-js/types@2.12.0
|
|
13
|
+
|
|
3
14
|
## 2.11.0
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -120,8 +120,8 @@ var plugin_default = () => ({
|
|
|
120
120
|
app = (0, import_express.default)();
|
|
121
121
|
initApp(app);
|
|
122
122
|
if (config) {
|
|
123
|
-
const { middleware
|
|
124
|
-
initMiddlewares(
|
|
123
|
+
const { middleware } = config;
|
|
124
|
+
initMiddlewares(middleware, app);
|
|
125
125
|
}
|
|
126
126
|
useRun(app);
|
|
127
127
|
(0, import_registerRoutes.default)(app, apiHandlerInfos);
|
package/dist/cjs/utils.js
CHANGED
|
@@ -84,17 +84,17 @@ const createRouteHandler = (handler) => {
|
|
|
84
84
|
throw error;
|
|
85
85
|
}
|
|
86
86
|
} else if ((0, import_bff_runtime.isSchemaHandler)(handler)) {
|
|
87
|
-
const
|
|
88
|
-
if (
|
|
89
|
-
if (
|
|
87
|
+
const result = await handler(input);
|
|
88
|
+
if (result.type !== "HandleSuccess") {
|
|
89
|
+
if (result.type === "InputValidationError") {
|
|
90
90
|
res.status(400);
|
|
91
91
|
} else {
|
|
92
92
|
res.status(500);
|
|
93
93
|
}
|
|
94
|
-
return res.json(
|
|
94
|
+
return res.json(result.message);
|
|
95
95
|
} else {
|
|
96
96
|
res.status(200);
|
|
97
|
-
return res.json(
|
|
97
|
+
return res.json(result.value);
|
|
98
98
|
}
|
|
99
99
|
} else if ((0, import_bff_core.isInputParamsDeciderHandler)(handler)) {
|
|
100
100
|
try {
|
|
@@ -110,17 +110,17 @@ const createRouteHandler = (handler) => {
|
|
|
110
110
|
return next(e);
|
|
111
111
|
}
|
|
112
112
|
} else {
|
|
113
|
-
const
|
|
113
|
+
const args = Object.values(input.params).concat(input);
|
|
114
114
|
try {
|
|
115
|
-
const
|
|
115
|
+
const body = await handler(...args);
|
|
116
116
|
if (res.headersSent) {
|
|
117
117
|
return await Promise.resolve();
|
|
118
118
|
}
|
|
119
|
-
if (typeof
|
|
120
|
-
return res.json(
|
|
119
|
+
if (typeof body !== "undefined") {
|
|
120
|
+
return res.json(body);
|
|
121
121
|
}
|
|
122
|
-
} catch (
|
|
123
|
-
return next(
|
|
122
|
+
} catch (e) {
|
|
123
|
+
return next(e);
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
};
|
package/dist/esm-node/plugin.js
CHANGED
|
@@ -88,8 +88,8 @@ var plugin_default = () => ({
|
|
|
88
88
|
app = express();
|
|
89
89
|
initApp(app);
|
|
90
90
|
if (config) {
|
|
91
|
-
const { middleware
|
|
92
|
-
initMiddlewares(
|
|
91
|
+
const { middleware } = config;
|
|
92
|
+
initMiddlewares(middleware, app);
|
|
93
93
|
}
|
|
94
94
|
useRun(app);
|
|
95
95
|
registerRoutes(app, apiHandlerInfos);
|
package/dist/esm-node/utils.js
CHANGED
|
@@ -51,17 +51,17 @@ const createRouteHandler = (handler) => {
|
|
|
51
51
|
throw error;
|
|
52
52
|
}
|
|
53
53
|
} else if (isSchemaHandler(handler)) {
|
|
54
|
-
const
|
|
55
|
-
if (
|
|
56
|
-
if (
|
|
54
|
+
const result = await handler(input);
|
|
55
|
+
if (result.type !== "HandleSuccess") {
|
|
56
|
+
if (result.type === "InputValidationError") {
|
|
57
57
|
res.status(400);
|
|
58
58
|
} else {
|
|
59
59
|
res.status(500);
|
|
60
60
|
}
|
|
61
|
-
return res.json(
|
|
61
|
+
return res.json(result.message);
|
|
62
62
|
} else {
|
|
63
63
|
res.status(200);
|
|
64
|
-
return res.json(
|
|
64
|
+
return res.json(result.value);
|
|
65
65
|
}
|
|
66
66
|
} else if (isInputParamsDeciderHandler(handler)) {
|
|
67
67
|
try {
|
|
@@ -77,17 +77,17 @@ const createRouteHandler = (handler) => {
|
|
|
77
77
|
return next(e);
|
|
78
78
|
}
|
|
79
79
|
} else {
|
|
80
|
-
const
|
|
80
|
+
const args = Object.values(input.params).concat(input);
|
|
81
81
|
try {
|
|
82
|
-
const
|
|
82
|
+
const body = await handler(...args);
|
|
83
83
|
if (res.headersSent) {
|
|
84
84
|
return await Promise.resolve();
|
|
85
85
|
}
|
|
86
|
-
if (typeof
|
|
87
|
-
return res.json(
|
|
86
|
+
if (typeof body !== "undefined") {
|
|
87
|
+
return res.json(body);
|
|
88
88
|
}
|
|
89
|
-
} catch (
|
|
90
|
-
return next(
|
|
89
|
+
} catch (e) {
|
|
90
|
+
return next(e);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
};
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "2.
|
|
14
|
+
"version": "2.12.0",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/cli/index.d.ts",
|
|
17
17
|
"main": "./dist/cjs/cli/index.js",
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
"formidable": "^1.2.2",
|
|
43
43
|
"reflect-metadata": "^0.1.13",
|
|
44
44
|
"type-is": "^1.6.18",
|
|
45
|
-
"@modern-js/bff-core": "2.
|
|
46
|
-
"@modern-js/bff-runtime": "2.
|
|
47
|
-
"@modern-js/types": "2.
|
|
48
|
-
"@modern-js/utils": "2.
|
|
45
|
+
"@modern-js/bff-core": "2.12.0",
|
|
46
|
+
"@modern-js/bff-runtime": "2.12.0",
|
|
47
|
+
"@modern-js/types": "2.12.0",
|
|
48
|
+
"@modern-js/utils": "2.12.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/cookie-parser": "^1.4.2",
|
|
@@ -61,11 +61,11 @@
|
|
|
61
61
|
"supertest": "^6.1.6",
|
|
62
62
|
"typescript": "^4",
|
|
63
63
|
"zod": "^3.17.3",
|
|
64
|
-
"@modern-js/core": "2.
|
|
65
|
-
"@modern-js/app-tools": "2.
|
|
66
|
-
"@modern-js/server-core": "2.
|
|
67
|
-
"@scripts/
|
|
68
|
-
"@scripts/
|
|
64
|
+
"@modern-js/core": "2.12.0",
|
|
65
|
+
"@modern-js/app-tools": "2.12.0",
|
|
66
|
+
"@modern-js/server-core": "2.12.0",
|
|
67
|
+
"@scripts/jest-config": "2.12.0",
|
|
68
|
+
"@scripts/build": "2.12.0"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
71
|
"express": "^4.17.1"
|