Skip to content

Commit 5818492

Browse files
committed
📘 doc: migrate from schema to inline
1 parent 2998845 commit 5818492

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

docs/concept/guard.md

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,34 +25,28 @@ Instead of duplicating an existing hook, you can define a shared hook scope usin
2525

2626
To encapsulate all hooks into the scope, instead of writing:
2727
```typescript
28-
app.post('/sign-up', (({ body }) => signUp(body), {
29-
schema: {
30-
body: t.Object({
31-
username: t.String(),
32-
password: t.String()
33-
})
34-
}
28+
app.post('/sign-up', ({ body }) => signUp(body), {
29+
body: t.Object({
30+
username: t.String(),
31+
password: t.String()
32+
})
3533
})
3634
.post('/sign-in', (({ body }) => signIn(body), {
3735
beforeHandle: isUserExists,
38-
schema: {
39-
body: t.Object({
40-
username: t.String(),
41-
password: t.String()
42-
})
43-
}
36+
body: t.Object({
37+
username: t.String(),
38+
password: t.String()
39+
})
4440
})
4541
```
4642
4743
You can group hook into `guard`:
4844
```typescript
4945
app.guard({
50-
schema: {
51-
body: t.Object({
52-
username: t.String(),
53-
password: t.String()
54-
})
55-
}
46+
body: t.Object({
47+
username: t.String(),
48+
password: t.String()
49+
})
5650
}, app => app
5751
.post('/sign-up', ({ body }) => signUp(body))
5852
.post('/sign-in', ({ body }) => signIn(body), {
@@ -69,7 +63,7 @@ You can create group with a guard scope by adding a guard api in the second para
6963
app.group('/v1', (app) =>
7064
app.guard(
7165
{
72-
body: t.Literal()
66+
body: t.Literal('Rikuhachima Aru')
7367
},
7468
(app) => app.get('/student', () => 'Rikuhachima Aru')
7569
)

0 commit comments

Comments
 (0)