1 | 'use strict'
|
2 |
|
3 | const fastify = require('../fastify')()
|
4 |
|
5 | fastify.use(require('cors')())
|
6 | fastify.use(require('dns-prefetch-control')())
|
7 | fastify.use(require('frameguard')())
|
8 | fastify.use(require('hide-powered-by')())
|
9 | fastify.use(require('hsts')())
|
10 | fastify.use(require('ienoopen')())
|
11 | fastify.use(require('x-xss-protection')())
|
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 | })
|