Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@fastify/routes
Advanced tools
Readme
This plugin decorates a Fastify instance with routes
, which is a Map of registered routes. Note that you have to register this plugin before registering any routes so that it can collect all of them.
The fastify.routes
Map has a key for each path any route has been registered, which points to an array of routes registered on that path. There can be more than one route for a given path if there are multiple routes added with different methods or different constraints.
{
'/hello': [
{
method: 'GET',
url: '/hello',
schema: { ... },
handler: Function,
prefix: String,
logLevel: String,
bodyLimit: Number,
constraints: undefined,
},
{
method: 'POST',
url: '/hello',
schema: { ... },
handler: Function,
prefix: String,
logLevel: String,
bodyLimit: Number,
constraints: { ... },
}
]
}
const fastify = require('fastify')()
fastify.register(require('@fastify/routes'))
fastify.get('/hello', {}, (request, reply) => {
reply.send({ hello: 'world' })
})
fastify.listen({ port: 3000 }, (err, address) => {
if (err) {
console.error(err)
return
}
console.log(fastify.routes)
/* will output a Map with entries:
{
'/hello': [
{
method: 'GET',
url: '/hello',
schema: Object,
handler: <Function>,
prefix: <String>,
logLevel: <String>,
bodyLimit: <Number>
}
]
}
*/
})
MIT License
FAQs
A plugin for Fastify that provides a map of routes
The npm package @fastify/routes receives a total of 4,656 weekly downloads. As such, @fastify/routes popularity was classified as popular.
We found that @fastify/routes demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 19 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.