miqro 7.2.4 → 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 +33 -1
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -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.4",
3
+ "version": "7.2.5",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "build/esm/src/lib.js",