Thanks for your interest in contributing. This guide covers everything you need to get started.
- Node.js 18+ (20 recommended)
- Redis 6.2+ running locally (or Docker)
- npm 9+
# Fork and clone the repo
git clone https://github.com/YOUR_USERNAME/nestjs-redisx.git
cd nestjs-redisx
# Install dependencies
npm install
# Build all packages
npm run build
# Run tests (requires Redis on localhost:6379)
npm testAll commands run from the repo root:
# Build
npm run build # Build all packages
npm run build -w @nestjs-redisx/cache # Build single package
# Test
npm test # Unit tests (all packages)
npm run test:e2e # E2E tests (requires Redis)
npm run test:integration # Integration tests (requires Redis)
npm test -- --coverage # Unit tests with coverage
# Code quality
npm run typecheck # TypeScript compilation check
npm run lint # ESLint
npm run format # Prettier auto-fix
npm run format:check # Prettier check# Standalone Redis
docker run -d --name redis -p 6379:6379 redis:7
# Cluster (for cluster integration tests)
./scripts/docker-cluster-up.sh
# Sentinel (for sentinel integration tests)
./scripts/docker-sentinel-up.sh-
Create a branch from
main:feat/descriptionfor new featuresfix/descriptionfor bug fixesdocs/descriptionfor documentation changes
-
Make your changes in the relevant
packages/directory. -
Write or update tests. All new code must have tests. PRs without tests must explain why tests are not applicable.
-
Run checks before committing:
npm run build
npm test
npm run typecheck
npm run lint
npm run format:check- Commit using Conventional Commits:
feat(cache): add TTL override for individual keys
fix(locks): handle renewal timeout on slow connections
docs(streams): add consumer group example
test(rate-limit): add sliding window edge cases
chore: update dependencies
Format: type(scope): description
Types: feat, fix, docs, test, chore, refactor, ci
Scope: package name without the @nestjs-redisx/ prefix (e.g., core, cache, locks).
- Push and open a Pull Request against
main.
packages/
core/ # Driver abstraction, plugin system
cache/ # L1+L2 caching, SWR, stampede protection
locks/ # Distributed locks
rate-limit/ # Rate limiting algorithms
idempotency/ # Request deduplication
streams/ # Redis Streams
metrics/ # Prometheus metrics
tracing/ # OpenTelemetry tracing
apps/
demo/ # Documentation code snippets source
example/ # Example application
website/ # VitePress documentation site
Each package follows the same structure:
packages/<name>/
src/ # Source code
test/
unit/ # Unit tests (mocked, no Redis needed)
integration/ # Integration tests (require Redis)
package.json
tsconfig.json
tsup.config.ts
vitest.config.ts
Unit tests are mocked and don't require Redis. Integration tests need a running Redis instance.
# Unit tests only (no Redis needed)
npm test
# Single package
npm test -w @nestjs-redisx/cache
# Integration tests (Redis required)
npm run test:integration
# E2E tests (Redis required)
npm run test:e2e
# Load and stress tests
npm run test:load
npm run test:stress
# Coverage report
npm test -- --coverage- Prettier for formatting (TypeScript files)
- ESLint for linting
- Both are enforced in CI
Run npm run format to auto-fix formatting.
- Keep PRs focused on a single change.
- Include tests for new functionality. If tests are not applicable, explain why in the PR description.
- Update documentation if the change affects the public API.
- Ensure CI passes before requesting review.
- Reference related issues in the PR description (e.g.,
Fixes #123).
Use the Bug Report template. Include a minimal reproduction.
Use the Feature Request template. Explain the use case and proposed API.
For questions and help, use GitHub Discussions instead of issues.
By contributing, you agree that your contributions will be licensed under the MIT License.