Auth & RBAC Boilerplate — Express + TypeScript + Prisma
Production-grade role-based access control with dual-token JWT rotation and Prisma ORM adapter.
Key Capabilities & Architecture
Dual-Token Lifecycle
Short-lived access tokens (15m) paired with long-lived refresh tokens (7d) with automatic rotation.
Drop-in Prisma ORM Persistence
Includes complete PostgreSQL, MySQL, and SQLite schema and adapter replacing prototype RAM stores.
Hierarchical RBAC Middleware
Express middleware factory: authorize(Role.ADMIN, Role.EDITOR) to safeguard sensitive endpoints.
Anti-Brute Force Protection
Integrated bcrypt password hashing (12 salt rounds), token revocation blacklist, and rate limiters.
Quick Setup & Installation Instructions
- npm install
- Copy .env.example to .env and set JWT_SECRET, JWT_REFRESH_SECRET, and DATABASE_URL
- Run npx prisma db push to apply migrations to your database
- Start development server with npm run dev or build with npm run build && npm start
Verified Compatibility & Requirements
One-time purchase • Unlimited commercial use • Instant download
Included in Your Download ZIP
- └─prisma/schema.prisma
- └─src/adapters/prisma-adapter.ts
- └─src/middleware/authenticate.ts
- └─src/middleware/authorize.ts
- └─src/middleware/rate-limiter.ts
- └─src/services/auth-service.ts
- └─src/services/token-service.ts
- └─src/routes/auth.routes.ts
- └─src/routes/protected.routes.ts
- └─src/types/index.ts
- └─src/index.ts
- └─README.md
import { Router } from 'express';
import { authenticate, authorize, Role } from './auth-rbac-boilerplate';
const router = Router();
// Protected: Admin and Editor only
router.post('/articles', authenticate, authorize(Role.ADMIN, Role.EDITOR), (req, res) => {
res.json({ success: true, createdBy: req.user.email });
});Frequently Asked Questions
Technical specifics and licensing details for this product.
Does it support database migrations?
Yes. Run npx prisma db push or npx prisma migrate dev with the included schema.prisma.
How does token invalidation work on logout?
The token service records revoked tokens into an active blacklist cache with automatic TTL eviction.