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