A simple Express.js REST API with dummy patient data for testing and development purposes.
- 20 example patient records with Indonesian names and data
- Full CRUD operations (Create, Read, Update, Delete)
- RESTful API endpoints
- CORS enabled
- JSON responses
- Install dependencies:
npm install- Start the server:
npm startThe server will run on http://localhost:3002
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
API information and documentation |
| GET | /patients |
Get all patients (supports pagination) |
| GET | /patients/:id |
Get patient by ID |
| POST | /patients |
Create new patient |
| PUT | /patients/:id |
Update patient by ID |
| DELETE | /patients/:id |
Delete patient by ID |
The /patients endpoint supports pagination with the following query parameters:
page: Page number (default: 1, minimum: 1)limit: Number of records per page (default: 10, maximum: 50, minimum: 1)
{
"success": true,
"count": 10,
"total": 20,
"pagination": {
"current": 1,
"total": 2,
"hasNext": true,
"hasPrev": false,
"limit": 10,
"next": 2
},
"data": [...]
}Each patient record contains:
{
"id": 1,
"nama": "Ahmad Subandi",
"namaIbuKandung": "Siti Aminah",
"tempatLahir": "Jakarta",
"tanggalLahir": "1985-03-15",
"namaAyah": "Budiman Subandi",
"noTelepon": "081234567890",
"statusPernikahan": "Menikah",
"agama": "Islam",
"pendidikan": "S1",
"sukuBangsa": "Jawa",
"golonganDarah": "A+",
"alamat": "Jl. Sudirman No. 123, Jakarta Selatan"
}curl http://localhost:3002/patients# Get first page (10 patients)
curl http://localhost:3002/patients?page=1&limit=10
# Get second page (10 patients)
curl http://localhost:3002/patients?page=2&limit=10
# Get first page with 5 patients only
curl http://localhost:3002/patients?page=1&limit=5curl http://localhost:3002/patients/1curl -X POST http://localhost:3002/patients \
-H "Content-Type: application/json" \
-d '{
"nama": "John Doe",
"namaIbuKandung": "Jane Doe",
"tempatLahir": "Jakarta",
"tanggalLahir": "1990-01-01",
"namaAyah": "Jack Doe",
"noTelepon": "081234567890",
"statusPernikahan": "Belum Menikah",
"agama": "Islam",
"pendidikan": "S1",
"sukuBangsa": "Jawa",
"golonganDarah": "A+",
"alamat": "Jl. Example No. 123"
}'curl -X PUT http://localhost:3002/patients/1 \
-H "Content-Type: application/json" \
-d '{
"nama": "Ahmad Subandi Updated",
"statusPernikahan": "Menikah"
}'curl -X DELETE http://localhost:3002/patients/1The API includes 20 sample patient records with diverse Indonesian names, representing various:
- Ethnic backgrounds (Jawa, Batak, Sunda, Melayu, Bugis, Dayak, etc.)
- Religions (Islam, Kristen, Hindu, Buddha)
- Education levels (SMA, D3, S1, S2)
- Blood types (A+, A-, B+, B-, AB+, AB-, O+, O-)
- Marital statuses (Menikah, Belum Menikah)
- Cities across Indonesia
- Built with Express.js
- Data separated into
datas.jsfor better organization - Uses in-memory data storage (data resets on server restart)
- CORS enabled for cross-origin requests
- JSON request/response format
test-api/
├── server.js # Main Express.js server and API routes
├── datas.js # Patient data
├── package.json # Dependencies and scripts
└── README.md # This file
MIT