Skip to content

Instantly share code, notes, and snippets.

@sekoyo
Last active February 1, 2022 16:39
Show Gist options
  • Save sekoyo/1518c81829b6231291c2b2364c143da7 to your computer and use it in GitHub Desktop.
Save sekoyo/1518c81829b6231291c2b2364c143da7 to your computer and use it in GitHub Desktop.
Fastify JSON Schema example
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