const routes = (fastify, options, done) => {
fastify.post('/login', async (request, reply) => {
return 'ok'
})
fastify.get('/getBooks', async (request, reply) => {
return 'OK'
})
fastify.get('/getUsers', async (request, reply) => {
return 'OK'
})
done()
}
module.exports = routes
定义路由后,再引用
fastify.register(require('./routes/index'), { prefix: '/v1' }) //添加路由前缀
console.log(`app run ip: ${APP_IP}`);
if (err) throw err
// lServer is now listening on ${address}
})
注册路由里可以定义路由前缀。
浙公网安备 33010602011771号