Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rate Limit API Calls #402

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Rate Limit API Calls #402

wants to merge 6 commits into from

Conversation

nik-dange
Copy link
Member

Info

Partially closes [#391].

Description

We're introducing rate limiting to prevent features like Express Checkin from being abused, since it's an unauthenticated route tied to SendGrid.

Changes

  • Created new Rate Limiting Middleware
  • TODO: add specific routes and config limits

Type of Change

  • Patch (non-breaking change/bugfix)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to not work as
    expected)
  • Documentation (A change to a README/description)
  • Continuous Integration/DevOps Change (Related to deployment steps, continuous integration
    workflows, linting, etc.)
  • Other: (Fill In)

If you've selected Patch, Minor, or Major as your change type, make sure to bump the version before merging in package.json!

Testing

I have tested that my changes fully resolve the linked issue ...

  • locally.
  • on the testing API/testing database.
  • with appropriate Postman routes. Screenshots are included below.

Checklist

  • I have performed a self-review of my own code.
  • I have followed the style guidelines of this project.
  • I have appropriately edited the API version in the package.json file.
  • My changes produce no new warnings.

Screenshots

Please include a screenshot of your Postman testing passing successfully.

TODO

Copy link

Thanks for contributing!
If you've made changes to the API's functionality, please make sure to bump the package
version—see this guide to semantic versioning for details—and
document those changes as appropriate.

});

use(req: express.Request, res: express.Response, next: express.NextFunction) {
if (req.path === '/api/v2/user') {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is kinda ugly, is there a more modular/cleaner way to check this? Ideally, we're only checking this against the express checkin route

@@ -53,4 +53,6 @@ const app = createExpressServer({
defaultErrorHandler: false,
});

app.set('trust proxy', 1);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this is ugly as well, it feels weird adding this app.set here. I don't think there's a way with our routing-controllers package to have the app.set config set, but maybe there's other ideas out there

Copy link
Contributor

@dowhep dowhep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will take a look again after u implemented the decorators.

@sumeet-bansal sumeet-bansal removed their request for review September 13, 2024 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants