Last active
May 17, 2018 03:35
-
-
Save israeleriston/7434fcd0be277f911e48ef3a4c452f50 to your computer and use it in GitHub Desktop.
Simple example the using fastify with default response
This file contains hidden or 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
'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