
Live Link : https://doctor-pateint.vercel.app/
This is the backend for the DoctorPatient application, deployed on Render:

🌐 Base URL: https://doctorpateint-1.onrender.com
💻 Tech Stack & Features:
- 🟦 TypeScript – Strongly typed backend
- 🗄️ Prisma ORM – Database modeling & queries
- 🔒 bcrypt – Password hashing for security
- 🛡️ JWT – Authentication & Authorization
- 🍪 res.cookie – Storing JWT tokens in HTTP cookies
- 🩺 Node.js + Express – REST API backend
- 🐘 PostgreSQL – Database
| Method | Endpoint | Description | Body / Notes |
|---|---|---|---|
| 📝 POST | /api/auth/register |
Register a new user | { "name": "John Doe", "role" : "DOCTOR" ,"email": "john@example.com", "password": "****" } |
| 🔑 POST | /api/auth/login |
Login user, returns JWT via cookie | { "email": "john@example.com", "password": "****" } |
| 🚪 POST | /api/auth/logout |
Logout user, clears JWT cookie | No body required |
Note: JWT token is set in HTTP-only cookie using
res.cookie().
| Method | Endpoint | Description | Notes |
|---|---|---|---|
| 👤 GET | /api/user/me |
Get logged-in user info | Requires JWT auth cookie |
| 📊 GET | /api/user/me/dash |
Get all users (dashboard) | Requires JWT auth cookie |
| Method | Endpoint | Description | Notes |
|---|---|---|---|
| 🩺 GET | /api/doctors |
Get all doctors | Requires JWT auth cookie |
| Method | Endpoint | Description | Body / Notes |
|---|---|---|---|
| 📅 POST | /api/appointments/ |
Book a new appointment | { "patientId": "...", "doctorId": "...", "date": "YYYY-MM-DDTHH:mm:ssZ" } |
| 📋 GET | /api/appointments/my |
Get patient appointments | Requires JWT auth cookie |
| 🏥 GET | /api/appointments/doctor |
Get doctor appointments | Requires JWT auth cookie |
| ✅ PATCH | /api/appointments/:id/complete |
Mark appointment as completed | Requires JWT auth cookie |
| Method | Endpoint | Description | Body / Notes |
|---|---|---|---|
| 💊 POST | /api/prescriptions/ |
Create a prescription | Requires JWT auth cookie |
| 📄 GET | /api/prescriptions/appointment/:appointmentId |
Get prescription for an appointment | Requires JWT auth cookie |
- Base URL:
https://doctorpateint-1.onrender.com - Include headers for authentication (JWT cookie is set automatically if logged in).
npm install
npm run build
node dist/index.js
npm run dev
const BASE_URL = "https://doctorpateint-1.onrender.com";
// Example: Get all doctors
fetch(`${BASE_URL}/api/doctors`, {
credentials: "include" // Important to send cookies
})
.then(res => res.json())
.then(data => console.log("🩺 Doctors:", data));const appointment = {
patientId: "123",
doctorId: "456",
date: "2025-08-25T10:00:00Z"
};
fetch(`${BASE_URL}/api/appointments/`, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
credentials: "include", // Send JWT cookie
body: JSON.stringify(appointment)
})
.then(res => res.json())
.then(data => console.log("📅 Appointment booked:", data));- 🔒 Passwords are hashed with bcrypt.
- 🛡️ JWT tokens are stored in HTTP-only cookies using
res.cookie(). - 🟦 TypeScript + Prisma ensures type safety for all database queries.
- Dates should follow ISO format:
YYYY-MM-DDTHH:mm:ssZ.