Skip to content

This is an example of an E-commerce API built with NestJS, which can be used as a reference in other projects.

License

Notifications You must be signed in to change notification settings

MeteSayan/nestjs-ecommerce-api

Repository files navigation

NestJS E-commerce API

NestJS TypeScript PostgreSQL

A modern and scalable e-commerce API built with NestJS framework, written in TypeScript, and using PostgreSQL database.

🚀 Features

  • 🔐 JWT-based authentication and authorization
  • 👥 User management (registration, login, profile management)
  • 🛍️ Product management (CRUD operations)
  • 📦 Order management
  • ⭐ Product reviews and ratings
  • 📑 Category management
  • 📚 Swagger UI API documentation
  • 🔄 TypeORM database management
  • 🧪 Jest testing infrastructure
  • 🔒 Security measures (Helmet, Compression)

🛠️ Technologies

  • Framework: NestJS
  • Programming Language: TypeScript
  • Database: PostgreSQL
  • ORM: TypeORM
  • API Documentation: Swagger UI
  • Testing: Jest
  • Security: JWT, Bcrypt, Helmet
  • Code Quality: ESLint, Prettier

📋 Prerequisites

  • Node.js (v14 or higher)
  • PostgreSQL
  • npm or yarn

🚀 Installation

  1. Clone the repository:
git clone https://github.com/MeteSayan/nestjs-ecommerce-api.git
cd nestjs-ecommerce-api
  1. Install dependencies:
npm install
  1. Configure database settings:
  • Update database connection details in config/default.json
  1. Run database migrations:
npm run migration:run

🏃‍♂️ Running the Application

# Development mode
npm run start:dev

# Production mode
npm run build
npm run start:prod

📚 API Documentation

Access the API documentation through Swagger UI:

http://localhost:3200/api/docs

🧪 Testing

# Run unit tests
npm run test

# Generate test coverage report
npm run test:cov

# Run E2E tests
npm run test:e2e

📦 Database Migrations

# Generate new migration
npm run migration:generate -- db/migrations/migration-name

# Run migrations
npm run migration:run

# Revert last migration
npm run migration:revert

🔐 Security

  • JWT-based authentication
  • Password hashing (Bcrypt)
  • Security headers with Helmet
  • Rate limiting
  • CORS configuration

📁 Project Structure

src/
├── users/           # User management
├── products/        # Product management
├── orders/          # Order management
├── categories/      # Category management
├── reviews/         # Product reviews
└── utils/           # Utility functions

🤝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'feat: Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

👨‍💻 Contact

Mete Sayan - GitHub

Project Link: https://github.com/MeteSayan/nestjs-ecommerce-api

About

This is an example of an E-commerce API built with NestJS, which can be used as a reference in other projects.

Topics

Resources

License

Stars

Watchers

Forks