fastify
Version:
Fast and low overhead web framework, for Node.js
32 lines (27 loc) • 612 B
JavaScript
const fs = require('fs')
const fastify = require('../fastify')({
https: {
key: fs.readFileSync('../test/https/fastify.key'),
cert: fs.readFileSync('../test/https/fastify.cert')
}
})
const schema = {
out: {
type: 'object',
properties: {
hello: {
type: 'string'
}
}
}
}
fastify
.get('/', schema, function (req, reply) {
reply.header('Content-Type', 'application/json').code(200)
reply.send({ hello: 'world' })
})
fastify.listen(3000, err => {
if (err) throw err
console.log(`server listening on ${fastify.server.address().port}`)
})