A robust and scalable starter project for Node.js, Express, MongoDB, TypeScript, and more. This project provides a solid foundation for developing modern backend applications with a modular architecture and advanced security features.
- JWT Authentication with refresh tokens
- OTP (One-Time Password) system for:
- Account verification
- Password reset
- Secure login
- Email update
- Phone verification
- Protection against common attacks (CSRF, XSS, etc.)
- Rate limiting and brute force protection
- Secure session management
- HTML and text email templates
- Email queue with Bull
- Templates for:
- Account creation
- Account verification
- Password reset
- OTP login
- Password reset confirmation
- Modular and scalable architecture
- Repository pattern for data access
- Centralized error handling
- Advanced logging
- Flexible configuration
- Node.js & Express
- TypeScript
- MongoDB with Mongoose
- Redis for caching and sessions
- Bull for queues
- JWT for authentication
- Nodemailer for emails
- Jest for testing
- Node.js (v14 or higher)
- MongoDB
- Redis
- Docker (optional)
- Clone the repository:
git clone https://github.com/fless-lab/Node-TypeScript-Wizard.git
cd Node-TypeScript-Wizard
- Install dependencies:
npm install
- Configure environment variables:
cp .env.example .env
# Edit .env with your configurations
- Start in development mode:
npm run start
# Start in development mode
npm run docker:launch
# Start in production mode
npm run docker:launch:prod
├── src/
│ ├── apps/ # Main applications and modules
│ ├── modules/ # Shared modules
│ │ ├── authz/ # Authentication and authorization
│ │ ├── features/ # Business features
│ │ └── shared/ # Shared utilities
│ └── server.ts # Entry point
├── templates/ # Email templates
├── tests/ # Unit and e2e tests
├── docs/ # Documentation
└── ...
The project uses a flexible configuration system based on environment variables. Main configurations include:
- Database configuration
- Redis configuration
- JWT configuration
- Email configuration
- Security configuration
- Logging configuration
POST /auth/register
- RegistrationPOST /auth/login
- LoginPOST /auth/refresh
- Refresh tokenPOST /auth/logout
- LogoutPOST /auth/forgot-password
- Password reset requestPOST /auth/reset-password
- Password reset
POST /auth/otp/generate
- Generate OTPPOST /auth/otp/validate
- Validate OTP
# Run all tests
npm test
# Run tests with coverage
npm run test:coverage
# Run e2e tests
npm run test:e2e
# Run tests in watch mode
npm run test:watch
The project includes email templates for different use cases:
account-creation
- Account creationemail-verification
- Email verificationotp-login
- OTP loginotp-reset-password
- Password resetpassword-reset-confirmation
- Password reset confirmationaccount-verified
- Account verified
The project implements several security measures:
- CSRF protection
- Security headers with Helmet
- Rate limiting
- Input validation
- Secure session management
- Brute force protection
- Structured logging with Winston
- Queue monitoring with Bull Board
- Request tracing with Morgan
Contributions are welcome! Please check CONTRIBUTING.md for guidelines.
This project is licensed under the ISC License. See the LICENSE file for details.
- fless-lab
- All contributors
- The open source community