1 | 'use strict'
|
2 |
|
3 | const fastify = require('../fastify')({ logger: true })
|
4 |
|
5 | const opts = {
|
6 | schema: {
|
7 | response: {
|
8 | '2xx': {
|
9 | type: 'object',
|
10 | properties: {
|
11 | greet: { type: 'string' }
|
12 | }
|
13 | }
|
14 | }
|
15 | }
|
16 | }
|
17 |
|
18 | fastify.register(function (instance, options, done) {
|
19 |
|
20 | instance.get('/hello', opts, (req, reply) => {
|
21 | reply.send({ greet: 'hello' })
|
22 | })
|
23 | done()
|
24 | }, { prefix: '/english' })
|
25 |
|
26 | fastify.register(function (instance, options, done) {
|
27 |
|
28 | instance.get('/hello', opts, (req, reply) => {
|
29 | reply.send({ greet: 'ciao' })
|
30 | })
|
31 | done()
|
32 | }, { prefix: '/italian' })
|
33 |
|
34 | fastify.listen({ port: 8000 }, function (err) {
|
35 | if (err) {
|
36 | throw err
|
37 | }
|
38 | })
|