You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
mahdi 7a46dd79ff Create shopping-card module 1 week ago
src Create shopping-card module 1 week ago
.env.sample Configure database initialization 2 weeks ago
.eslintrc.js Configure database initialization 2 weeks ago
.gitignore Configure database initialization 2 weeks ago
.prettierrc Configure database initialization 2 weeks ago
README.md Add readme.md file 2 weeks ago
nest-cli.json Configure database initialization 2 weeks ago
package-lock.json Implement receipt module 1 week ago
package.json Implement receipt module 1 week ago
tsconfig.build.json Configure database initialization 2 weeks ago
tsconfig.json Configure database initialization 2 weeks ago

README.md

CRUD

Backend API for E-commerce Application

This is a simple Backend Service API for a E-commerce Application with various endpoints built using Nest.js, PostgreSQL & Sequelize.


Features

  • Built with Nest.js.
  • PostgreSQL and Sequelize for database management.
  • Implements JWT Authentication.
  • RESTful APIs for user management:
    • Create, Read, Update, and Delete (CRUD) operations.

Technologies Used

  • Nest.js
  • PostgreSQL with Sequelize
  • JWT for authentication
  • ARGON2 for password hashing

Installation and Setup

Prerequisites

  • Node.js and npm installed on your system.
  • postgreSQL connection (local or cloud).

1. Clone the Repository

git clone https://github.com/MahdiTajikKazemi/e-commerce-api-nestjs-postgres-sequelize

2. Setup Backend

  1. Install dependencies:
    npm install
    
  2. Create a .env file in the backend directory and configure it:
    Set your environment variables in .env.sample file.
    
  3. Start the server:
    npm run start:dev
    

Usage

  1. Start the backend server.
  2. Open your 'Postman' | 'insomnia' or whatever testing api app you are comfortable using and then begin hitting enpoints listed below.

API Endpoints

Authentication

  • POST /api/v1/auth/signup: Register a new user and get a JWT token.
  • POST /api/v1/auth/login: Login and get a JWT token.

User Management

  • GET /api/v1/users/: Get a list of all users (admin only).
  • POST /api/v1/users/: Create a user (admin only).
  • PATCH /api/v1/users/:id: Update a specific user (admin only).
  • DELETE /api/v1/users/:id: Remove a specific user (admin only).
  • GET /api/v1/users/:id: Get a specific user (admin only).

Folder Structure

└── 📁src
    └── 📁core
        └── 📁constants
            └── index.ts
        └── 📁database
            └── database.config.ts
            └── database.module.ts
            └── database.providers.ts
            └── 📁interfaces
                └── dbConfig.interface.ts
    └── 📁modules
        └── 📁auth
            └── auth.controller.ts
            └── auth.module.ts
            └── auth.service.ts
            └── jwt.strategy.ts
            └── local.strategy.ts
        └── 📁orders
            └── 📁dto
                └── create-order.dto.ts
                └── index.ts
                └── update-order.dto.ts
            └── 📁entities
                └── order-status.entity.ts
                └── order.entity.ts
            └── order-statuses.providers.ts
            └── orders.controller.ts
            └── orders.module.ts
            └── orders.providers.ts
            └── orders.service.ts
        └── 📁products
            └── 📁dto
                └── create-product.dto.ts
                └── index.ts
                └── update-product.dto.ts
            └── 📁entities
                └── product.entity.ts
            └── products.controller.ts
            └── products.module.ts
            └── products.providers.ts
            └── products.service.ts
        └── 📁users
            └── 📁dto
                └── create-user.dto.ts
                └── index.ts
                └── update-user.dto.ts
            └── 📁entities
                └── user.entity.ts
            └── users.controller.ts
            └── users.module.ts
            └── users.providers.ts
            └── users.service.ts
    └── app.controller.ts
    └── app.module.ts
    └── app.service.ts
    └── main.ts

Future Enhancements

  • Integrate redis for cashing

License

This project is licensed under the MIT License.

Mahdi Tajik Kazemi