express-zod-safe 1.0.5 → 1.0.7
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 +2 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
Express Zod Safe is a strict, typesafe middleware designed for Node.js applications, leveraging the robustness of Zod schemas to validate incoming request bodies, parameters, and queries. This package seamlessly integrates with Express.js (or similar frameworks) to provide developers with a typesafe, declarative approach to ensure data integrity and prevent invalid or malicious data from affecting their applications.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
_This package was inspired by Aquila169's [zod-express-middleware](https://github.com/Aquila169/zod-express-middleware) package, and is intended to be a more robust and typesafe alternative._
|
|
14
14
|
|
|
15
15
|
## 🔒 Features
|
|
16
16
|
|
|
@@ -65,7 +65,7 @@ app.post('/user/:userId', validate({ params, query, body }), (req, res) => {
|
|
|
65
65
|
app.listen(3000, () => console.log('Server running on port 3000'));
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
**Note:** The `validate` middleware must be used **after** any other middleware that parses/modifies the request body, such as `express.json()` or `express.urlencoded()`.
|
|
69
69
|
|
|
70
70
|
### ⚠️ URL Parameters & Query Strings Coercion
|
|
71
71
|
As mentioned in the example above, all URL parameters and query strings are parsed as strings. This means that if you have a URL parameter or query string that is expected to be a number, you must use the `z.coerce.number()` method to coerce the value to a number. This is because Zod will not coerce the value for you, and will instead throw an error if the value is not a string.
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-zod-safe",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "TypeScript-friendly middleware designed for Express applications, leveraging the robustness of Zod schemas to validate incoming request bodies, parameters, and queries.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/AngaBlue/
|
|
8
|
+
"url": "git+https://github.com/AngaBlue/express-zod-safe.git"
|
|
9
9
|
},
|
|
10
10
|
"keywords": [
|
|
11
11
|
"zod",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"author": "AngaBlue <contact@anga.blue>",
|
|
19
19
|
"license": "LGPL-3.0-or-later",
|
|
20
20
|
"bugs": {
|
|
21
|
-
"url": "https://github.com/AngaBlue/
|
|
21
|
+
"url": "https://github.com/AngaBlue/express-zod-safe/issues"
|
|
22
22
|
},
|
|
23
|
-
"homepage": "https://github.com/AngaBlue/
|
|
23
|
+
"homepage": "https://github.com/AngaBlue/express-zod-safe#readme",
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@angablue/eslint-config": "^1.4.4",
|
|
26
26
|
"@types/node": "^20.10.7",
|