miqro 7.2.4 → 7.2.6
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 +35 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -281,7 +281,40 @@ 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 } from "miqro";
|
|
288
|
+
import { JSONParser } from "@miqro/core";
|
|
289
|
+
|
|
290
|
+
export default defineRoute({
|
|
291
|
+
name: "create post",
|
|
292
|
+
method: "POST",
|
|
293
|
+
middleware: [JSONParser()],
|
|
294
|
+
request: {
|
|
295
|
+
body: {
|
|
296
|
+
title: "string",
|
|
297
|
+
content: "string"
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
response: {
|
|
301
|
+
status: [200],
|
|
302
|
+
body: {
|
|
303
|
+
id: "number"
|
|
304
|
+
}
|
|
305
|
+
},
|
|
306
|
+
handler: async (req, res) => {
|
|
307
|
+
const post = await req.server.db.get("mydb")
|
|
308
|
+
.insert("posts")
|
|
309
|
+
.values({ title: req.body.title, content: req.body.content })
|
|
310
|
+
.returning("id")
|
|
311
|
+
.yield();
|
|
312
|
+
return res.json({ id: post[0].id });
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
full declaration with validation but no req.body typing:
|
|
285
318
|
|
|
286
319
|
```ts
|
|
287
320
|
import { APIRoute, JSONParser } from "@miqro/core";
|
|
@@ -420,7 +453,7 @@ without `cors.ts` all origins are allowed. with it only listed origins are accep
|
|
|
420
453
|
|
|
421
454
|
## ORM
|
|
422
455
|
|
|
423
|
-
quick reference. full docs in [@miqro/query](query
|
|
456
|
+
quick reference. full docs in [@miqro/query](https://www.npmjs.com/package/@miqro/query).
|
|
424
457
|
|
|
425
458
|
```ts
|
|
426
459
|
import { defineModel } from "@miqro/query";
|