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.
 

151 lines
4.0 KiB

# 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
```bash
git clone https://github.com/MahdiTajikKazemi/e-commerce-api-nestjs-postgres-sequelize
```
### 2. Setup Backend
1. Install dependencies:
```bash
npm install
```
2. Create a `.env` file in the `backend` directory and configure it:
```env
Set your environment variables in .env.sample file.
```
3. Start the server:
```bash
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