/
erioxis
/
web-nodejs
Обзор
Документация
Войти
/
erioxis
/
web-nodejs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
backend/node_modules/fastify/examples/route-prefix.js
38 строк
763 B
erioxis
lab11fix
15 дек 2025, 23:21
15 дек 2025, 23:21
70dc7ba
Код
Авторство
О чём код?
'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 } })