Skip to content

feat: Redis rate limiter and shared pagination helper#9

Merged
sumdahl merged 1 commit into
mainfrom
feat/redis-rate-limiter
May 13, 2026
Merged

feat: Redis rate limiter and shared pagination helper#9
sumdahl merged 1 commit into
mainfrom
feat/redis-rate-limiter

Conversation

@sumdahl

@sumdahl sumdahl commented May 13, 2026

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings May 13, 2026 04:39
@sumdahl
sumdahl merged commit 61f8e93 into main May 13, 2026
2 checks passed
@sumdahl
sumdahl deleted the feat/redis-rate-limiter branch May 13, 2026 04:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a Redis-backed rate limiter implementation and factors repeated count(*) pagination logic into a shared helper, aligning infrastructure services with Redis and reducing query duplication across repositories.

Changes:

  • Added RedisRateLimiterService and wired it into the DI container as the default IRateLimiterService.
  • Introduced a shared countAll SQL helper and updated user/role repositories to use it for pagination totals.
  • Replaced inline count(*) SQL in repositories with the shared helper.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/server/infrastructure/services/redis-rate-limiter.service.ts Adds Redis-backed rate limiter implementation.
src/server/infrastructure/persistence/user.pg.repository.ts Uses shared countAll helper for total row counting.
src/server/infrastructure/persistence/role.pg.repository.ts Uses shared countAll helper for totals and user-role counts.
src/server/infrastructure/di/container.ts Switches rate limiter DI binding from in-memory to Redis.
src/server/infrastructure/db/pagination.ts Adds reusable countAll SQL snippet for pagination.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +16 to +21
const redisKey = `${KEY_PREFIX}${key}`;
const count = await this.redis.incr(redisKey);

if (count === 1) {
await this.redis.pexpire(redisKey, windowMs);
}
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