A scalable Express.js project with TypeScript featuring CRUD with pagination, filtering, sorting, file uploads, soft delete, RBAC, JWT authentication, access and audit logs, and cron jobs for scheduled tasks.
- Role-Based Access Control (RBAC) – Fine-grained access control for different user roles and permissions.
- CRUD Operations – Create, Read, Update, Delete endpoints out of the box.
- Pagination, Filtering, Sorting, Searching – Easily manage large datasets with built-in pagination, query-based filtering, and sorting mechanisms.
- File Upload – Upload and manage files using multer.
- Soft Delete – Soft-delete support using timestamps instead of permanently removing data.
- Multi Delete & Multi Create – Perform bulk operations with ease.
- Authentication & Login – Token-based login system using JWT.
- Access Logs – Track all incoming requests for monitoring and debugging.
- Audit Logs – Record data changes with before/after snapshots for critical actions.
- Cron Jobs – Scheduled background tasks using node-cron.
- Job Queue – Queued background tasks using Redis & BullMQ.
- Express.js – Web framework
- TypeScript – Static type-checking
- MySQL – Database
- Knex – Query Builder
- JWT – Authentication
- Multer – File uploads
- Node-Cron – Scheduled jobs
- Redis & BullMQ – Job Queue
- Morgan – Logging
- Docker - Containerization
- ESLint, Prettier - Controlling code quality
- Husky - Git hook
- Admin dashboards
- Internal tools
- APIs for web/mobile apps
- SaaS backends
- Docker - Download Docker 🐳
- Docker Compose - Usually comes with Docker Desktop
git clone https://github.com/MinPyaeKyaw/rbac-expressjs-starter.git
cd rbac-expressjs-starter-
Configure database credentials (Optional but recommended):
Before starting, you may want to update the database credentials in
docker-compose.ymlfor security:- Open
docker-compose.yml - Update the MySQL service environment variables:
MYSQL_ROOT_PASSWORD- Set your MySQL root passwordMYSQL_PASSWORD- Set your MySQL user password (should matchMYSQL_ROOT_PASSWORDif using root)
- Update the app service environment variables to match:
DB_USER- MySQL username (default:root)DB_PASSWORD- MySQL password (must matchMYSQL_ROOT_PASSWORD)
- Update the MySQL healthcheck password to match your
MYSQL_ROOT_PASSWORD
Example:
mysql: environment: - MYSQL_ROOT_PASSWORD=your_secure_password - MYSQL_PASSWORD=your_secure_password app: environment: - DB_USER=root - DB_PASSWORD=your_secure_password
- Open
-
Build and start all services (MySQL, Redis, and the Express app):
docker compose up --buildThis will automatically:
- Start a MySQL 8.0 database
- Start a Redis server for job queues
- Wait for MySQL to be ready (healthcheck)
- Automatically run database migrations to create all tables
- Automatically run database seeds to populate initial data
- Build and start the Express.js application
-
Access the application:
- API Server: http://localhost:3000
- MySQL Database: localhost:3306
- Redis: localhost:6379
-
Log in with these credentials (from seed data):
The seeds run automatically, so you can immediately log in with any of these test users:
- Admin User
- Username:
admin - Password:
admin123
- Username:
- Super Admin User
- Username:
superadmin - Password:
admin123
- Username:
- Developer User
- Username:
developer - Password:
password123
- Username:
- Test User
- Username:
testuser - Password:
password123
- Username:
- Admin User
If you prefer to run without Docker for development:
- Install dependencies:
npm install-
Set up environment variables:
- Copy
.env.exampleto.env(if available) - Configure your local MySQL and Redis connections
- Copy
-
Run database migrations and seeds:
# Run migrations to create database tables
npm run db:migrate
# Run seeds to populate initial data
npm run db:seed- Start the development server:
npm run devNote:
- When using Docker, migrations and seeds run automatically on container startup
- Do not run SQL schema files directly. Always use migrations to manage your database schema
- API Documentation: Read README.md in feature folders
- Technical Documentation: Read here
- 📄 Postman collection can be found in
src/docsfolder. Get [here](src/docs/rbac_express.postman_collection. - 📝 Read detailed technical documentation here
Sai Min Pyae Kyaw
💼 Passionate Full Stack Developer | Node.js | TypeScript | React | MySQL
📍 Based in Myanmar
Made with ❤️ by Sai Min Pyae Kyaw
