I am working on a Node Express/Angular Civic project that is integrated with a 3rd party API. Each call costs me $1.00. I am funding a certain portion of it but then I would like the POST request to the 3rd party to stop. The reason is I don't want to end up with thousands of dollars of cost. 3rd party API doesn't support rate limit.
I can build a database, or create auth but I prefer not to go that route or integrate payment gateway. But I don't prefer any of these solutions for personal reasons. I came across a partial solution/node-module (express-rate-limit) which is limiting per IP Address. But this still doesn't solve the problem of stop making requests after it reaches x number of calls.
var RateLimit = require('express-rate-limit');
app.enable('trust proxy'); // only if you're behind a reverse proxy (Heroku, Bluemix, AWS if you use an ELB, custom Nginx setup, etc)
var apiLimiter = new RateLimit({
windowMs: 15*60*1000, // 15 minutes
max: 1, // 1 call every 15 minutes
delayMs: 0 // disabled
});
// only apply to requests that begin with /api/
app.use('/api/', apiLimiter);
Are there any better solutions/best practices? It's just a side project that can help several people but I don't want to go broke by bearing the cost if many people start using it. Thanks!