UNPKG

753 BJavaScriptView Raw
1'use strict'
2
3const fs = require('fs')
4const path = require('path')
5const fastify = require('../fastify')({
6 https: {
7 key: fs.readFileSync(path.join(__dirname, '../test/https/fastify.key')),
8 cert: fs.readFileSync(path.join(__dirname, '../test/https/fastify.cert'))
9 }
10})
11
12const opts = {
13 schema: {
14 response: {
15 '2xx': {
16 type: 'object',
17 properties: {
18 hello: {
19 type: 'string'
20 }
21 }
22 }
23 }
24 }
25}
26
27fastify
28 .get('/', opts, function (req, reply) {
29 reply.header('Content-Type', 'application/json').code(200)
30 reply.send({ hello: 'world' })
31 })
32
33fastify.listen(3000, err => {
34 if (err) throw err
35 console.log(`server listening on ${fastify.server.address().port}`)
36})