简体   繁体   中英

API using sails.js in node

I have to make an API subscription with the following info provided-

When a user hits any API then as per unique identifier of the user API requests are limited Such as suppose there are 2 users with different groups - Group1 and Group2 Group1 has a limit of 5 requests per second (RPS) for a particular API (API1) Group2 has a limit of 6 requests per second (RPS) for the same API (API2).

Any ideas on how to implement this would help!

You will need to have some logic where you can keep data of user group and there limitations and access to set of API endpoints, use caching database (like redis) for caching and other persistent database of your choice (like mongodb) and in every request have middleware to check limitations and increment access.

Also check below link to understand concepts https://blog.logrocket.com/rate-limiting-node-js/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM