The Telehealth API allows users to book appointments with doctors and enables doctors to view their scheduled appointments. This API is built using Node.js, TypeScript, Express, and MongoDB.
- User registration and login
- Appointment booking
- Doctor appointment management
- Token-based authentication
-
Clone the repository:
git clone https://github.com/YOUR_USERNAME/Telehealth-API.git cd Telehealth-API
-
Install dependencies:
npm install
-
Set up environment variables:
Create a
.env
file in the root directory and add the following:MONGO_URI=mongodb://localhost:27017/telehealth JWT_SECRET=your_jwt_secret PORT=5000
-
Build the project:
npm run build
-
Run the application:
npm run dev
The server will start on
http://localhost:5000
.
- MONGO_URI: MongoDB connection string.
- JWT_SECRET: Secret key for JWT signing and verification.
- PORT: Port on which the server will run.
-
Register a new user:
POST /api/auth/register
- Request body:
{ "username": "string", "email": "string", "password": "string", "role": "user" | "doctor" }
-
Login:
POST /api/auth/login
- Request body:
{ "email": "string", "password": "string" }
- Response:
{ "token": "jwt_token" }
-
Book an appointment:
POST /api/appointments
- Headers:
Authorization: Bearer <jwt_token>
- Request body:
{ "doctorId": "doctor_id", "dateTime": "ISO8601_date", "description": "optional_description" }
-
Get appointments for a doctor:
GET /api/appointments/:doctorId
- Headers:
Authorization: Bearer <jwt_token>
POST /api/auth/register
POST /api/auth/login
POST /api/appointments
GET /api/appointments/:doctorId
Errors are returned with appropriate status codes and messages. Ensure to handle errors as described:
401 Unauthorized
: No token provided or invalid token.400 Bad Request
: Invalid request data.500 Internal Server Error
: General server error.
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Commit your changes (
git commit -am 'Add new feature'
). - Push to the branch (
git push origin feature-branch
). - Create a new Pull Request.
This project is licensed under the MIT License. See the LICENSE file for details.
Feel free to customize this README to fit your specific needs and provide more details as necessary. This template provides a solid foundation for documenting your API.