Home / File/ route-prefix.js — fastify Source File

route-prefix.js — fastify Source File

Architecture documentation for route-prefix.js, a javascript file in the fastify codebase.

Entity Profile

Source Code

'use strict'

const fastify = require('../fastify')({ logger: true })

const opts = {
  schema: {
    response: {
      '2xx': {
        type: 'object',
        properties: {
          greet: { type: 'string' }
        }
      }
    }
  }
}

fastify.register(function (instance, options, done) {
  // the route will be '/english/hello'
  instance.get('/hello', opts, (req, reply) => {
    reply.send({ greet: 'hello' })
  })
  done()
}, { prefix: '/english' })

fastify.register(function (instance, options, done) {
  // the route will be '/italian/hello'
  instance.get('/hello', opts, (req, reply) => {
    reply.send({ greet: 'ciao' })
  })
  done()
}, { prefix: '/italian' })

fastify.listen({ port: 8000 }, function (err) {
  if (err) {
    throw err
  }
})

Frequently Asked Questions

What does route-prefix.js do?
route-prefix.js is a source file in the fastify codebase, written in javascript.
Where is route-prefix.js in the architecture?
route-prefix.js is located at examples/route-prefix.js (directory: examples).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free