@mingjue8888/express-plus 1.0.1 → 1.1.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/README.md +4 -4
- package/package.json +1 -1
- package/{valid-response.ts → valid-send.ts} +1 -1
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ import hasLogin from "@mingjue8888/express-plus/has-login";
|
|
|
29
29
|
import Router from "@mingjue8888/express-plus/router";
|
|
30
30
|
import validBody from "@mingjue8888/express-plus/valid-body";
|
|
31
31
|
import validParam from "@mingjue8888/express-plus/valid-param";
|
|
32
|
-
import
|
|
32
|
+
import validSend from "@mingjue8888/express-plus/valid-send";
|
|
33
33
|
|
|
34
34
|
// File ./routers/routerA.ts
|
|
35
35
|
const login: Router = {
|
|
@@ -50,7 +50,7 @@ const login: Router = {
|
|
|
50
50
|
const id = "UUID";
|
|
51
51
|
res.signToken(id);
|
|
52
52
|
}),
|
|
53
|
-
|
|
53
|
+
validSend({
|
|
54
54
|
accessToken: Joi.string()
|
|
55
55
|
.required(),
|
|
56
56
|
}),
|
|
@@ -74,7 +74,7 @@ const findUser: Router = {
|
|
|
74
74
|
asyncMiddleware(async function (req, res) {
|
|
75
75
|
throw new NotFoundUserError();
|
|
76
76
|
}),
|
|
77
|
-
|
|
77
|
+
validSend({
|
|
78
78
|
id: Joi.string()
|
|
79
79
|
.required(),
|
|
80
80
|
|
|
@@ -98,7 +98,7 @@ const findUserPosts: Router = {
|
|
|
98
98
|
posts: []
|
|
99
99
|
}
|
|
100
100
|
}),
|
|
101
|
-
|
|
101
|
+
validSend({
|
|
102
102
|
posts: Joi.array().items(Joi.object().keys({
|
|
103
103
|
id: Joi.string().required(),
|
|
104
104
|
content: Joi.string().required().default(""),
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@ import Joi from "joi";
|
|
|
2
2
|
import asyncMiddleware from "./async-middleware";
|
|
3
3
|
import ServerErrorResponseError from "./server-error-response-error";
|
|
4
4
|
|
|
5
|
-
export default function
|
|
5
|
+
export default function validSend(sch: Record<string, Joi.AnySchema>) {
|
|
6
6
|
return asyncMiddleware(async function (_req, res) {
|
|
7
7
|
const { error, value } = Joi
|
|
8
8
|
.object(sch)
|