File tree Expand file tree Collapse file tree 1 file changed +14
-20
lines changed Expand file tree Collapse file tree 1 file changed +14
-20
lines changed Original file line number Diff line number Diff line change @@ -25,34 +25,28 @@ Instead of duplicating an existing hook, you can define a shared hook scope usin
25
25
26
26
To encapsulate all hooks into the scope, instead of writing:
27
27
``` 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
+ })
35
33
})
36
34
.post (' /sign-in' , (({ body }) => signIn (body ), {
37
35
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
+ })
44
40
})
45
41
` ` `
46
42
47
43
You can group hook into ` guard ` :
48
44
` ` ` typescript
49
45
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
+ })
56
50
}, app => app
57
51
.post (' /sign-up' , ({ body }) => signUp (body ))
58
52
.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
69
63
app .group (' /v1' , (app ) =>
70
64
app .guard (
71
65
{
72
- body: t .Literal ()
66
+ body: t .Literal (' Rikuhachima Aru ' )
73
67
},
74
68
(app ) => app .get (' /student' , () => ' Rikuhachima Aru' )
75
69
)
You can’t perform that action at this time.
0 commit comments