Created
February 6, 2019 21:58
-
-
Save Eomm/2e6e01a02e06d34256c767e076b5562f to your computer and use it in GitHub Desktop.
Fastify Snippet
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
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