Created
January 6, 2022 09:11
-
-
Save delvedor/fd9b55c7acc7343796af6ea0c51a297f to your computer and use it in GitHub Desktop.
This file contains 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
import Fastify from 'fastify' | |
import { TypeBoxTypeProvider, Type } from 'fastify-type-provider-typebox' | |
const fastify = Fastify({ | |
ajv: { | |
customOptions: { | |
strict: 'log', | |
keywords: ['kind', 'modifier'] | |
} | |
} | |
}).withTypeProvider<TypeBoxTypeProvider>() | |
fastify.route({ | |
method: 'GET', | |
path: '/route', | |
schema: { | |
querystring: Type.Object({ | |
foo: Type.Number(), | |
bar: Type.String() | |
}) | |
}, | |
handler: (request, reply) => { | |
// type Query = { foo: number, bar: string } | |
const { foo, bar } = request.query // type safe! | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think:
should be:
Also
Type
isn't used.