Skip to content

talShtark/products-api

Repository files navigation

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective Support us

Project Overview

This project is an implementation of a REST API for managing a store's inventory system. It allows for creating, updating, deleting, and retrieving products, as well as querying products based on various criteria such as stock levels, popularity, and search terms.

Architecture and Design Patterns

  • Repository Pattern: Abstracts the data access layer from the business logic layer, promoting code reusability and testability.
  • Dependency Injection: Utilizes NestJS's dependency injection to promote loose coupling between components for better maintainability.
  • Separation of Concerns: Divides the codebase into distinct layers like repositories, services, controllers, and DTOs for improved maintainability.
  • Error Handling: Implements custom exceptions and a global exception filter for consistent and centralized error management.
  • Validation: Integrates with the class-validator library for defining and enforcing validation rules via DTOs.
  • Clean Code Practices: Adheres to practices like DRY, using descriptive names, and organizing code into reusable units.

Key Features

  • Product Creation: Allows creating new products with unique name validation.
  • Product Updates: Supports updating existing products, including name uniqueness checks.
  • Product Deletion: Facilitates deleting products, ensuring no pending orders exist.
  • Product Listing: Offers sorting, pagination, and search filtering for listing products.
  • Low Stock Query: Retrieves products with stock levels below a specified threshold.
  • Popularity Query: Identifies the most popular products based on sales data.

Project Structure

  • repositories/: Houses the repository implementations and interfaces.
  • services/: Contains the business logic services.
  • controllers/: Manages the API route controllers.
  • dtos/: Defines Data Transfer Objects for input validation.
  • entities/: Includes the entity definitions (e.g., Product class).
  • exceptions/: Contains custom exception classes for error handling.

Installation

$ npm install

Running the app

# development
$ npm run start

API will be available at http://localhost:3000/api

Test

# unit tests
$ npm run test

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors