This project is an e-commerce API built with Express and TypeScript, using MongoDB with Mongoose for data management. Data validation is handled using zod.
Clone the repository
git clone https://github.com/mdrafi276/next-level-assignment-2.git
cd next-level-assignment-2
📦 Install Dependencies
$ npm install
PORT=5000
DB_URI="mongodb://localhost:27017/next-level-assignment-2"
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
The server should be running on http://localhost:5000.
-
Product Management
- Create a new product
- Retrieve all products
- Retrieve a specific product by ID
- Update product information
- Delete a product
- Search for products by name
-
Order Management
- Create a new order
- Retrieve all orders
- Retrieve orders by user email
- Update inventory when an order is created
- Endpoint:
/api/products
- Method:
POST
- Endpoint:
/api/products
- Method:
GET
- Endpoint:
/api/products/:productId
- Method:
GET
- Endpoint:
/api/products/:productId
- Method:
PUT
- Endpoint:
/api/products/:productId
- Method:
DELETE
- Endpoint:
/api/products?searchTerm=iphone
- Method:
GET
- Endpoint:
/api/orders
- Method:
POST
- Endpoint:
/api/orders
- Method:
GET
- Endpoint:
/api/orders?email=level2@programming-hero.com
- Method:
GET
npm run lint
npm run lint:fix