a. Open VS Code and create a new folder for your project.
b. Initialize a new Node.js project by running this command:
npm init -yRun this command to install the necessary packages:
npm install express mongoose bcryptjs jsonwebtoken dotenv cors express-validatorCreate a .env file in the root folder and add the following:
PORT=3000
DB_CONNECT=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret
In package.json, change the "main" field to server.js.
Run the server using:
npx nodemon- URL:
http://localhost:3000/users/register - Body (raw JSON):
{
"firstName": "John",
"lastName": "Doe",
"email": "john@example.com",
"password": "password123",
"dob": "1990-01-01",
"userType": "Customer",
"contactNumber": 1234567890
}- URL:
http://localhost:3000/users/login - Body (raw JSON):
{
"email": "john@example.com",
"password": "password123"
}- URL:
http://localhost:3000/users/order - Headers: Add
AuthorizationwithBearer <token>(replace<token>with the token from login). - Body (raw JSON):
{
"customerId": "<user_id>",
"partnerId": "<partner_id>",
"orderDetail": {
"startLocation": "123 Start St",
"endLocation": "456 End Ave",
"category": "X",
"description": "Test order",
"situation": "Normal"
},
"status": "Ongoing"
}- URL:
http://localhost:3000/users/order/<order_id> - Headers: Add
AuthorizationwithBearer <token>.
Replace <order_id> with an actual order ID.
- URL:
http://localhost:3000/users/address - Headers: Add
Authorizationwith `Bearer <