Skip to content

Instantly share code, notes, and snippets.

@israeleriston
Last active May 17, 2018 03:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save israeleriston/7434fcd0be277f911e48ef3a4c452f50 to your computer and use it in GitHub Desktop.
Save israeleriston/7434fcd0be277f911e48ef3a4c452f50 to your computer and use it in GitHub Desktop.
Simple example the using fastify with default response
'use strict'
const fastify = require('fastify')()
const handler = (req, reply) => {
reply.send({ hello: 'world' })
}
const route = {
method: 'GET',
url: '/',
schema: {
querystring: {
name: { type: 'string' },
excitement: { type: 'integer' }
},
response: {
200: {
type: 'object',
properties: {
hello: { type: 'string' }
}
}
}
}
}
fastify.route(route, handler)
fastify.listen(3000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment