miqro 7.2.3 → 7.2.5
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 +34 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ miqro
|
|
|
32
32
|
|
|
33
33
|
`@miqro/test` and `@miqro/request` are being phased out in favor of `node:test` and built-in `fetch`.
|
|
34
34
|
|
|
35
|
-
package docs: [@miqro/core](core
|
|
35
|
+
package docs: [@miqro/core](https://www.npmjs.com/package/@miqro/core) · [@miqro/query](https://www.npmjs.com/package/@miqro/query) · [@miqro/jsx](https://www.npmjs.com/package/@miqro/jsx) · [@miqro/jsx-dom](https://www.npmjs.com/package/@miqro/jsx-dom) · [@miqro/jsx-node](https://www.npmjs.com/package/@miqro/jsx-node) · [@miqro/request](https://www.npmjs.com/package/@miqro/request) · [@miqro/runner](https://www.npmjs.com/package/@miqro/runner) · [@miqro/test](https://www.npmjs.com/package/@miqro/test) · [@miqro/test-http](https://www.npmjs.com/package/@miqro/test-http) · [@miqro/parser](https://www.npmjs.com/package/@miqro/parser)
|
|
36
36
|
|
|
37
37
|
## composition
|
|
38
38
|
|
|
@@ -281,7 +281,39 @@ export default (req, res) => {
|
|
|
281
281
|
}
|
|
282
282
|
```
|
|
283
283
|
|
|
284
|
-
full declaration with validation:
|
|
284
|
+
full declaration with validation and typing:
|
|
285
|
+
|
|
286
|
+
```ts
|
|
287
|
+
import { defineRoute, JSONParser } from "@miqro/core";
|
|
288
|
+
|
|
289
|
+
export default defineRoute({
|
|
290
|
+
name: "create post",
|
|
291
|
+
method: "POST",
|
|
292
|
+
middleware: [JSONParser()],
|
|
293
|
+
request: {
|
|
294
|
+
body: {
|
|
295
|
+
title: "string",
|
|
296
|
+
content: "string"
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
response: {
|
|
300
|
+
status: [200],
|
|
301
|
+
body: {
|
|
302
|
+
id: "number"
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
handler: async (req, res) => {
|
|
306
|
+
const post = await req.server.db.get("mydb")
|
|
307
|
+
.insert("posts")
|
|
308
|
+
.values({ title: req.body.title, content: req.body.content })
|
|
309
|
+
.returning("id")
|
|
310
|
+
.yield();
|
|
311
|
+
return res.json({ id: post[0].id });
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
full declaration with validation but no req.body typing:
|
|
285
317
|
|
|
286
318
|
```ts
|
|
287
319
|
import { APIRoute, JSONParser } from "@miqro/core";
|