CoolFace
Apppublic

strong-tie/inbound-calls

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
route-prefix.js39 linesDownload Raw Back to examples
1'use strict'2 3const fastify = require('../fastify')({ logger: true })4 5const opts = {6  schema: {7    response: {8      '2xx': {9        type: 'object',10        properties: {11          greet: { type: 'string' }12        }13      }14    }15  }16}17 18fastify.register(function (instance, options, done) {19  // the route will be '/english/hello'20  instance.get('/hello', opts, (req, reply) => {21    reply.send({ greet: 'hello' })22  })23  done()24}, { prefix: '/english' })25 26fastify.register(function (instance, options, done) {27  // the route will be '/italian/hello'28  instance.get('/hello', opts, (req, reply) => {29    reply.send({ greet: 'ciao' })30  })31  done()32}, { prefix: '/italian' })33 34fastify.listen({ port: 8000 }, function (err) {35  if (err) {36    throw err37  }38})39