This API is designed for managing healthcare services, allowing users to create, read, update, and delete service records. Built with Node.js, Express.js, and MongoDB, it provides a simple interface for managing services, ensuring data integrity through validation and structured responses.
- CRUD Operations: Easily create, read, update, and delete services.
- Validation: Ensure valid input for service name, description, and price.
- Auto-generated IDs: Each service record has a unique identifier.
- URL:
/service/find - Method:
GET - Description: Retrieves a list of all services.
- URL:
/service/find/id - Method:
GET - Description: Fetches a service by its unique ID.
- Response:
- 200 OK: Returns the service object if found.
- 404 Not Found: Returns an error message if no service is found with the given ID.
- URL:
/service/create - Method:
POST - Request Body:
{ "service_name": "string", "description": "string", "price": number } - Description: Adds a new service record.
- Response:
- 201 Created: Returns the created service object.
- URL:
/service/update/id - Method:
PUT - Request Body:
{ "service_name": "string", "description": "string", "price": number } - Description: Updates an existing service by its ID. Users can update only necessary fields.
- Response:
- 200 OK: Returns the updated service object.
- 404 Not Found: Returns an error message if no service is found with the given ID.
- URL:
/service/delete/id - Method:
DELETE - Description: Removes a service from the database by its ID.
- Response:
- 204 No Content: Indicates the service has been successfully deleted.
- 404 Not Found: Returns an error message if no service is found with the given ID.
-
Clone the repository:
git clone <repository-url>
-
Navigate to the Project Directory: Change your current directory to the project folder:
cd healthcare-service-management-api -
Install Dependencies: Install the necessary Node.js packages by running:
npm install
-
Set Up Environment Variables: Create a .env file in the root directory of the project and add the following variables:
MONGODB_URI=<your-mongodb-connection-string> PORT=8080
Replace with your actual MongoDB connection string.
-
Start the Server: Start the API server with the following command:
npm run start
The server will run on http://localhost:8080.
-
Test the Endpoints: Use Postman or any other API testing tool to interact with the API endpoints.
This project is licensed under the MIT License - see the LICENSE file for details.