File size: 433 Bytes
23ac194
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// works on Node v14.13.0+
import { fastify } from '../fastify.js'

const app = fastify({
  logger: true
})

const schema = {
  schema: {
    response: {
      200: {
        type: 'object',
        properties: {
          hello: {
            type: 'string'
          }
        }
      }
    }
  }
}

app.get('/', schema, async function (req, reply) {
  return { hello: 'world' }
})

app.listen({ port: 3000 }).catch(console.error)