1 | 'use strict'
|
2 |
|
3 | const fs = require('node:fs')
|
4 | const path = require('node:path')
|
5 | const 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 | logger: true
|
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({ port: 3000 }, err => {
|
35 | if (err) {
|
36 | throw err
|
37 | }
|
38 | })
|