minimonolith 0.13.0 → 0.13.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/README.md +5 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -112,8 +112,7 @@ This file contains the `get:id` method handler for the `todo` service. It retrie
|
|
|
112
112
|
```js
|
|
113
113
|
// todo/get/index.js
|
|
114
114
|
export default async ({ body, MODELS }) => {
|
|
115
|
-
|
|
116
|
-
return await MODELS.todo.findOne({ where: { id } });
|
|
115
|
+
return await MODELS.todo.findOne({ where: { id: body.id } });
|
|
117
116
|
}
|
|
118
117
|
```
|
|
119
118
|
|
|
@@ -126,8 +125,9 @@ This file validates the `get:id` method's input, ensuring that the provided `id`
|
|
|
126
125
|
import { z, DB_VALIDATION } from 'minimonolith';
|
|
127
126
|
|
|
128
127
|
export default (MODELS, ROUTE_CODE) => ({
|
|
129
|
-
id: z.string()
|
|
130
|
-
DB_VALIDATION.
|
|
131
|
-
|
|
128
|
+
id: z.string()
|
|
129
|
+
.superRefine(DB_VALIDATION.isSafeInt('id'))
|
|
130
|
+
.transform(id => parseInt(id))
|
|
131
|
+
.superRefine(DB_VALIDATION.exists(MODELS.todo, 'id')),
|
|
132
132
|
})
|
|
133
133
|
```
|