Developed a Node.js Express application with TypeScript as the programming language, integrating MongoDB with Mongoose for user data and order management.
Make sure you have the following installed on your machine:
- Node.js
- npm (Node Package Manager)
- MongoDB
- Endpoint: POST
https://level2a2.vercel.app/api/users
- Endpoint:GET
https://level2a2.vercel.app/api/users
- Endpoint:GET
https://level2a2.vercel.app/api/users/:userId
- Sample
https://level2a2.vercel.app/api/users/6560959a59445230cb868eeb
- Endpoint: PUT
https://level2a2.vercel.app/api/users/:userId
- Endpoint:DELETE
https://level2a2.vercel.app/api/users/:userId
- Endpoint:PUT
https://level2a2.vercel.app/api/users/:userId/orders
- Endpoint:GET
https://level2a2.vercel.app/api/users/:userId/orders
- Sample
https://level2a2.vercel.app/api/users/6560959a59445230cb868eeb/orders
- Endpoint:GET
https://level2a2.vercel.app/api/users/:userId/orders/total-price
- Sample
https://level2a2.vercel.app/api/users/:6560959a59445230cb868eeb/orders/total-price
-
Clone the repository:
git clone https://github.com/oliullah05/Mongoose-Express-Typescript-CRUD.git
-
Install Dependencies:
cd your-repository npm install
-
Set Up Environment Variables:
Create a
.env
file in the root of your project and configure any necessary environment variables.PORT=5000 MONGODB_URI=mongodb://localhost:27017/your-database BCRYPT_SALT_ROUNDS=12 NODE_ENV= development
-
Run the Application:
npm run dev
Your application should now be running on http://localhost:5000.
- Create a new user Endpoint: POST /api/users
- Retrieve a list of all users Endpoint: GET /api/users
- Retrieve a specific user by ID Endpoint: GET /api/users/:userId
- Update user information Endpoint: PUT /api/users/:userId
- Delete a user Endpoint: DELETE /api/users/:userId
- Add New Product in Order Endpoint: PUT /api/users/:userId/orders
- Retrieve all orders for a specific user Endpoint: GET /api/users/:userId/orders
- Calculate Total Price of Orders for a Specific User Endpoint: GET /api/users/:userId/orders/total-price
Regards,
Oliullah Bhuiyan