Last active
February 1, 2022 16:39
-
-
Save dominictobias/1518c81829b6231291c2b2364c143da7 to your computer and use it in GitHub Desktop.
Fastify JSON Schema example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fastify.get<{ Querystring: { address: string } }>( | |
'/checkAddress', | |
{ | |
schema: { | |
querystring: { | |
type: 'object', | |
properties: { | |
postcode: { type: 'string' }, | |
}, | |
required: ['postcode'], | |
}, | |
}, | |
}, | |
async (req, reply) => { | |
reply.type('application/json').code(200) | |
return { postCode: req.query.postCode } | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment