Steps:
- Using npm init -y cmd initialize the Node.js project with a default package.json file
- Installing other npm pakages like express, mysql, nodemon
- Than creating the MVC arch for code readability
- Creating the index.js file and set up the express server
- Set up the MySQL db connection
- Open the cmd prompt, log in to Your MySQl Db, Than create a db, select that db and create a table
- In controller file the the main logic
- In routes file importing the controller and creating seperate route for that api
- Than importing that routes file to index.js file to use as middleware
End Points: https://localhost:3000/slot
Tech Stack:
[
Node Js,
Express Js,
MySQL
]
Request Body JSON:
{
"date": "2023/03/02",
"startSlotTime": "15:30",
"endSlotTime": "15:40"
}
Success Response:
{
"status": true,
"message": "Slot Booked Successfully"
}
Error Response:
{
"status": false,
"error": "This Slot is already Booked, Try another Slot"
}