Skip to content

fless-lab/Node-TypeScript-Wizard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

237 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Node-TypeScript-Wizard

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.

🌟 Features

πŸ” Authentication & Security

  • 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

πŸ“§ Email System

  • HTML and text email templates
  • Email queue with Bull
  • Templates for:
    • Account creation
    • Account verification
    • Password reset
    • OTP login
    • Password reset confirmation

πŸ— Architecture

  • Modular and scalable architecture
  • Repository pattern for data access
  • Centralized error handling
  • Advanced logging
  • Flexible configuration

πŸ›  Technologies

  • Node.js & Express
  • TypeScript
  • MongoDB with Mongoose
  • Redis for caching and sessions
  • Bull for queues
  • JWT for authentication
  • Nodemailer for emails
  • Jest for testing

πŸš€ Installation

Prerequisites

  • Node.js (v14 or higher)
  • MongoDB
  • Redis
  • Docker (optional)

Local Installation

  1. Clone the repository:
git clone https://github.com/fless-lab/Node-TypeScript-Wizard.git
cd Node-TypeScript-Wizard
  1. Install dependencies:
npm install
  1. Configure environment variables:
cp .env.example .env
# Edit .env with your configurations
  1. Start in development mode:
npm run start

Docker Installation

# Start in development mode
npm run docker:launch

# Start in production mode
npm run docker:launch:prod

πŸ“ Project Structure

β”œβ”€β”€ 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
└── ...

πŸ”§ Configuration

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

πŸ“ API Endpoints

Authentication

  • POST /auth/register - Registration
  • POST /auth/login - Login
  • POST /auth/refresh - Refresh token
  • POST /auth/logout - Logout
  • POST /auth/forgot-password - Password reset request
  • POST /auth/reset-password - Password reset

OTP

  • POST /auth/otp/generate - Generate OTP
  • POST /auth/otp/validate - Validate OTP

πŸ§ͺ Testing

# 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

πŸ“§ Email Templates

The project includes email templates for different use cases:

  • account-creation - Account creation
  • email-verification - Email verification
  • otp-login - OTP login
  • otp-reset-password - Password reset
  • password-reset-confirmation - Password reset confirmation
  • account-verified - Account verified

πŸ” Security

The project implements several security measures:

  • CSRF protection
  • Security headers with Helmet
  • Rate limiting
  • Input validation
  • Secure session management
  • Brute force protection

πŸ“ˆ Monitoring and Logging

  • Structured logging with Winston
  • Queue monitoring with Bull Board
  • Request tracing with Morgan

🀝 Contributing

Contributions are welcome! Please check CONTRIBUTING.md for guidelines.

πŸ“„ License

This project is licensed under the ISC License. See the LICENSE file for details.

πŸ‘₯ Authors

  • fless-lab

πŸ™ Acknowledgments

  • All contributors
  • The open source community

About

A base project template for Node.js API applications built with TypeScript. Includes configurations for Docker, authentication, logging, and basic CRUD operations. Perfect for rapid scaffolding with the NTW CLI (based on node-ts-starter).

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors