1 | 'use strict'
|
2 |
|
3 | const fs = require('node:fs')
|
4 | const path = require('node: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 | logger: true
|
12 | })
|
13 |
|
14 | const opts = {
|
15 | schema: {
|
16 | response: {
|
17 | '2xx': {
|
18 | type: 'object',
|
19 | properties: {
|
20 | hello: {
|
21 | type: 'string'
|
22 | }
|
23 | }
|
24 | }
|
25 | }
|
26 | }
|
27 | }
|
28 |
|
29 | fastify
|
30 | .get('/', opts, function (req, reply) {
|
31 | reply.header('Content-Type', 'application/json').code(200)
|
32 | reply.send({ hello: 'world' })
|
33 | })
|
34 |
|
35 | fastify.listen({ port: 3000 }, err => {
|
36 | if (err) {
|
37 | throw err
|
38 | }
|
39 | })
|