File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed
examples/with-fastify/src Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -14,12 +14,23 @@ fastify.register(FastifySteno, {
1414} )
1515
1616fastify . get ( '/' , ( ) => {
17- const users = fastify . steno . get < Users > ( 'users' )
18- return users ? .data
17+ const users = fastify . steno . get < Users > ( 'users' ) !
18+ return users . data
1919} )
2020
21- fastify . post ( '/' , { schema : { body : { $ref : 'User' } } } , ( req ) => {
22- return req . body
21+ fastify . post < { Body : User } > (
22+ '/' ,
23+ { schema : { body : { $ref : 'User' } } } ,
24+ async ( req ) => {
25+ const users = fastify . steno . get < Users > ( 'users' ) !
26+ users . data ! . users . push ( req . body )
27+ await users . write ( )
28+ return users . data
29+ }
30+ )
31+
32+ fastify . get ( '/schemas' , ( ) => {
33+ return fastify . getSchemas ( )
2334} )
2435
2536fastify . listen ( { host : '0.0.0.0' , port : 3000 } , ( err , address ) => {
You can’t perform that action at this time.
0 commit comments