This API manages users and their orders. This API is developed by using Express.js, TypeScript, and Mongoose.
live API: https://mongoose-express-crud-beta.vercel.app/
- Clone the repository:
git clone https://github.com/Nasim043/mongoose-express-crud.git
cd mongoose-express-crud
npm install
Create a .env file in the root directory with:
PORT=5000
DATABASE_URL=your_mongo_url
BCRYPT_SALT_ROUNDS=10
npm run build
npm run dev
- Create a user
- Endpoint:
POST /api/users
- Description: Create a new user.
- Endpoint:
- Get all users
- Endpoint:
GET /api/users
- Description: Retrieves a list of all users.
- Endpoint:
- Get user by ID
- Endpoint:
GET /api/users/:userId
- Description: Retrieves user details by ID.
- Endpoint:
- Update user by ID
- Endpoint:
PUT /api/users/:userId
- Description: Update user details by ID.
- Endpoint:
- Delete a user by ID
- Endpoint:
DELETE /api/users/:userId
- Description: Deletes a user by ID.
- Endpoint:
- Add New Product in Order
- Endpoint:
GET /api/users/:userId
- Description: Add New Product in Order by user ID.
- Endpoint:
- Retrieve all orders for a user
- Endpoint:
GET /api/users/:userId/orders
- Description: Retrieve all orders for a specific user by user ID.
- Endpoint:
- Calculate Total Price of Orders
- Endpoint:
GET /api/users/:userId/orders/total-price
- Description: Calculate the Total Price of Orders for Specific Users by User ID.
- Endpoint: