An open API service indexing awesome lists of open source software.

https://github.com/fless-lab/Node-TypeScript-Wizard

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).
https://github.com/fless-lab/Node-TypeScript-Wizard

api hacktoberfest node typescript

Last synced: about 1 year ago
JSON representation

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

Awesome Lists containing this project

README

          

# 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:
```bash
git clone https://github.com/fless-lab/Node-TypeScript-Wizard.git
cd Node-TypeScript-Wizard
```

2. Install dependencies:
```bash
npm install
```

3. Configure environment variables:
```bash
cp .env.example .env
# Edit .env with your configurations
```

4. Start in development mode:
```bash
npm run start
```

### Docker Installation

```bash
# 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

```bash
# 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](CONTRIBUTING.md) for guidelines.

## ๐Ÿ“„ License

This project is licensed under the ISC License. See the [LICENSE](LICENSE) file for details.

## ๐Ÿ‘ฅ Authors

- fless-lab

## ๐Ÿ™ Acknowledgments

- All contributors
- The open source community