Skip to content

Configured rate limiting for the app server#149

Merged
salazarsebas merged 5 commits intoHarmonia-Development:mainfrom
benedictfred:feat/rate-limiting
Sep 23, 2025
Merged

Configured rate limiting for the app server#149
salazarsebas merged 5 commits intoHarmonia-Development:mainfrom
benedictfred:feat/rate-limiting

Conversation

@benedictfred
Copy link
Contributor

Description

This pull request introduces rate limiting to the stellar-wallet service to help prevent abuse and excessive requests to key endpoints. It adds a new middleware for rate limiting, applies it to the authentication, KYC, and wallet routes, and includes configuration options and tests to verify the middleware's behavior.

Changes made

Rate limiting implementation:

  • Added a new rate-limit.ts middleware using the express-rate-limit package, with separate limiters for authentication, KYC, and wallet endpoints (authLimiter, kycLimiter, walletLimiter). Each limiter is configured with appropriate limits and response messages.
  • Integrated the rate limiters into the main app by applying them to the /auth, /kyc, and /wallet routes in index.ts.
  • Added environment variables (RATE_LIMIT_WINDOW_MS, RATE_LIMIT_MAX) to .env.example to allow configuration of rate limiting parameters.

Dependency and configuration updates:

  • Added express-rate-limit as a dependency in services/stellar-wallet/package.json to support rate limiting middleware.
  • Updated the main package.json to include Stellar SDK-related packages in the pnpm configuration.

Testing:

  • Added comprehensive tests for the rate limiting middleware in rate-limit.test.ts, verifying that each limiter behaves as expected and enforces limits.

Linked Issue

The PR closes issue #140

Screenshots

image

@salazarsebas
Please review. If there are changes to be made, tell me. Thanks.

@salazarsebas
Copy link
Contributor

Hey @benedictfred , please fix the errors thrown by the workflow. According to the output, the packages were added to the package json but the npm install command was not run, so the lock was not generated as expected.

@benedictfred
Copy link
Contributor Author

GM @salazarsebas
Please check it out to know if it's all good. Thanks.

@salazarsebas
Copy link
Contributor

@benedictfred
Copy link
Contributor Author

@salazarsebas
GM Sire.
The error is not coming from what I worked on actually. But let me try and fix it

@benedictfred
Copy link
Contributor Author

@salazarsebas
Check it now. The problem was that the cross-env package was looking for a missing dependency. So I installed that dependency, the workflow should work successfully now 🙏.

Copy link
Contributor

@salazarsebas salazarsebas left a comment

Choose a reason for hiding this comment

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

LGTM

@salazarsebas salazarsebas merged commit 4cca034 into Harmonia-Development:main Sep 23, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants