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.
Files changed (2) hide show
  1. package/README.md +34 -2
  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-README.md) · [@miqro/query](query-README.md) · [@miqro/jsx](jsx-README.md) · [@miqro/jsx-dom](jsx-dom-README.md) · [@miqro/jsx-node](jsx-node-README.md) · [@miqro/request](request-README.md) · [@miqro/runner](runner-README.md) · [@miqro/test](test-README.md) · [@miqro/test-http](test-http-README.md) · [@miqro/parser](parser-README.md)
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";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "miqro",
3
- "version": "7.2.3",
3
+ "version": "7.2.5",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "build/esm/src/lib.js",