ITADN

Support rate limit groups for specific routes

#369ClosedOleksandrBoiko1 创建于 2024-06-27
good first issue
O
OleksandrBoiko1commented
### Prerequisites - [X] I have written a descriptive issue title - [ ] I have searched existing issues to ensure the feature has not already been requested ### 🚀 Feature Proposal It'll be great to have an option to apply rate limit for this two endpoints, not for the whole project. Something that required [here](https://github.com/fastify/fastify-rate-limit/issues/58). Because solution from [issues](https://github.com/fastify/fastify-rate-limit/issues/58#issuecomment-539918830) is not working Important notice, I mean that rateLimit should calculate calls for this two endpoints, not separate ```js const routes: FastifyPluginAsync = async function (f) { const fastify = f.withTypeProvider<ZodTypeProvider>(); fastify.post( '/', { schema: { tags: SCHEMA_TAGS, body: BodySchema, response: { 200: ResponseSchema } } }, async (req) => { // Doing something } ); fastify.get( '/', { schema: { tags: SCHEMA_TAGS, response: { 200: ResponseSchema } } }, async (req) => { // Doing something } ); }; export default routes; ``` Thanks! ### Motivation Usefull feature! ### Example Register fastifyRateLimit only for encapsulate endpoints `fastify.register(fastifyRateLimit, { config: { rateLimit: { max: 3, timeWindow: '1 minute' } } })`
关闭于 2024-10-04 5 条评论