Skip to content
Public template

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Boilerplate Express - Production Ready

A high-performance, scalable, and secure Express.js boilerplate featuring advanced authentication, caching, and storage integration.


Features

Advanced Authentication

  • 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).

Core Capabilities

  • 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.

Tech Stack

  • 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

Project Structure

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.)

Installation

1. Clone & Install

git clone <repository>
cd BOILERPLATE-EXPRESS
npm install

2. Configure Environment

Copy .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

3. Database Migration

npx sequelize-cli db:migrate

4. Start Server

npm run dev

API Endpoints (Auth)

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

License

MIT License - Build something amazing!

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages