UNPKG

793 BJavaScriptView Raw
1'use strict'
2
3const fastify = require('../fastify')()
4
5fastify.use(require('cors')())
6fastify.use(require('dns-prefetch-control')())
7fastify.use(require('frameguard')())
8fastify.use(require('hide-powered-by')())
9fastify.use(require('hsts')())
10fastify.use(require('ienoopen')())
11fastify.use(require('x-xss-protection')())
12
13const opts = {
14 schema: {
15 response: {
16 '2xx': {
17 type: 'object',
18 properties: {
19 hello: {
20 type: 'string'
21 }
22 }
23 }
24 }
25 }
26}
27
28fastify
29 .get('/', opts, function (req, reply) {
30 reply.header('Content-Type', 'application/json').code(200)
31 reply.send({ hello: 'world' })
32 })
33
34fastify.listen(3000, err => {
35 if (err) throw err
36 console.log(`server listening on ${fastify.server.address().port}`)
37})