Commit 1eea5ee
committed
feat(nodejs): add rate limiting and request validation middleware
Rate Limiting:
- Add IP-based rate limiting using express-rate-limit
- Default limit: 100 requests/minute for most endpoints
- High limit: 1000 requests/minute for /metrics endpoint
- Strict limit: 10 requests/minute for sensitive endpoints
- Factory function for custom rate limits
- Proper IPv6 handling with validate option
Request Validation:
- Add comprehensive request validation middleware
- Field presence validation (requireFields)
- Type validation (validateTypes)
- Constraint validation (min, max, pattern, enum)
- URL parameter validation (validateParams)
- Query parameter validation (validateQuery)
- Combined validator factory (validate)
Additional fixes:
- Downgrade uuid from v13 to v9 for CommonJS/Jest compatibility
- Update jest.config.js with transformIgnorePatterns
- Add rate_limiting info to root endpoint response
- Apply validation to cache POST endpoint as example1 parent a95c9ae commit 1eea5ee
7 files changed
Lines changed: 773 additions & 232 deletions
File tree
- reference-apps/nodejs
- src
- middleware
- routes
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
25 | 29 | | |
0 commit comments