A progressive Node.js framework for building efficient and scalable server-side applications.
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.
- 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.
- 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.
- 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.
$ npm install# development
$ npm run start
API will be available at http://localhost:3000/api# unit tests
$ npm run test