Skip to content

Instantly share code, notes, and snippets.

@Eomm
Created February 6, 2019 21:58
Show Gist options
  • Save Eomm/2e6e01a02e06d34256c767e076b5562f to your computer and use it in GitHub Desktop.
Save Eomm/2e6e01a02e06d34256c767e076b5562f to your computer and use it in GitHub Desktop.
Fastify Snippet
const fastify = require('./fastify')({ logger: { level: 'debug' } })
fastify.addSchema({
$id: 'http://example.com/ref-to-external-validator.json',
type: 'object',
properties: {
hello: { type: 'string' }
}
})
const body = {
type: 'array',
items: { $ref: 'http://example.com/ref-to-external-validator.json#' },
default: []
}
fastify.route({
method: 'POST',
url: '/',
schema: { body },
handler: (_, r) => { r.send('ok') }
})
fastify.listen(3000).catch(console.log)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment