This is a simple user management application built with Express.js, MongoDB, and Zod for validation.
Check out the live demo: User Management App
- Create a new user
- Retrieve all users
- Retrieve a single user
- Update a user's information
- Delete a user
- Add an order for a user
- View all orders for a user
- Calculate the total price of all orders for a user
- Node.js and npm installed
- MongoDB installed and running
-
Clone the repository:
git clone https://github.com/sm-alamin/second-assignment.git
-
Change into the project directory:
cd second-assignment
-
Install dependencies:
npm install
-
Set up your MongoDB database and update the connection string in
config.js
. -
Start the application:
npm run start:dev
-
Open your browser and navigate to (http://localhost:5000).
POST /api/users
### Get all user
```http
GET /api/users
### Get a single user
```http
GET /api/users/:userId
### Update user
```http
PUT /api/users/:userId
### Delete user
```http
DELETE /api/users/:userId
### Add an Order for a User
```http
PUT /api/users/:userId/orders
### Get All Orders for a User
```http
GET /api/users/:userId/orders
### Calculate Total Price of Orders for a User
```http
GET /api/users/:userId/orders/total-price