A high-performance, scalable, and secure Express.js boilerplate featuring advanced authentication, caching, and storage integration.
- Dynamic Refresh Token Rotation - Enhanced security using UUID-based tokens to prevent replay attacks.
- Silent Refresh - Automatic token renewal via global middleware for a seamless user experience.
- Redis-Powered Sessions - High-performance session management using Dragonfly (Redis-compatible).
- Smart Remember Me - Intelligent session handling:
- With Remember Me: Continuous session rotation (infinite as long as active).
- Without Remember Me: Strict 7-day absolute expiration from initial login.
- OTP Password Reset - Secure flow using 6-digit OTP sent via SMTP (Nodemailer).
- Modular Architecture - Organized by domains (Auth, User, etc.) for easy scalability.
- Optimized Logging - Clean, single-line request/response summaries using Pino-pretty.
- Object Storage - Comprehensive RustFS integration for uploading, deleting, and generating public/presigned URLs.
- Secure Cookies - HttpOnly, Secure, SameSite: None (Partitioned) for cross-domain stability.
- Robust Validation - Schema-based validation using Zod.
- Backend: Express.js 5.x
- Database: PostgreSQL + Sequelize ORM
- Cache/Session: Dragonfly (Redis)
- Email: Nodemailer (SMTP)
- Security: Argon2 (Hashing), JWT (Access Tokens), UUID (Refresh Tokens)
- Logging: Pino + Pino-Http
BOILERPLATE-EXPRESS/
├── src/
│ ├── modules/
│ │ ├── auth/ # Login, Register, OTP, Reset Password
│ │ └── user/ # User Profile & Management
│ ├── middleware/ # Auth (Strict/Optional), Logger, Upload
│ └── utils/
│ ├── jwt.js # Token management
│ ├── dragonfly.js # Cache & Session store
│ ├── mailer.js # SMTP Email sender
│ └── logger.js # Custom Pino configuration
├── db/
│ ├── models/ # Sequelize models
│ ├── migrations/ # Database migrations
│ └── seeders/ # Initial data
└── config/ # Service configurations (RustFS, DB, etc.)
git clone <repository>
cd BOILERPLATE-EXPRESS
npm installCopy .env.example to .env and fill in your credentials:
- DATABASE_DSN: PostgreSQL connection string
- JWT_ACCESS_SECRET: Secure random string
- DRAGONFLY_ADDR: Redis/Dragonfly endpoint
- MAIL_*: SMTP credentials for OTP
npx sequelize-cli db:migratenpm run dev| Method | Endpoint | Description |
|---|---|---|
POST |
/auth/login |
Sign in with email/username |
POST |
/auth/register |
Create new account |
POST |
/auth/logout |
End session & clear cookies |
GET |
/auth/me |
Get current user profile |
POST |
/auth/request-otp |
Request password reset OTP |
POST |
/auth/verify-otp |
Verify OTP & get reset grant |
POST |
/auth/reset-password |
Reset password using grant token |
MIT License - Build something amazing!