Update README
Some checks failed
Go-test / build (push) Has been cancelled

This commit is contained in:
2025-09-12 10:19:57 +07:00
parent 4a0488c352
commit c542d5e51b

184
README.md
View File

@@ -8,7 +8,6 @@
- [✨ Fitur Utama](#-fitur-utama)
- [🏗️ Arsitektur](#%EF%B8%8F-arsitektur)
- [⚡ Quick Start](#-quick-start)
- [🔐 Autentikasi](#-autentikasi)
- [📊 API Endpoints](#-api-endpoints)
- [🛠️ Development](#%EF%B8%8F-development)
- [🚀 Deployment](#-deployment)
@@ -20,10 +19,7 @@
### Core Features
- **🔒 JWT Authentication** - Sistem autentikasi yang aman
- **📦 CRUD Operations** - Operasi lengkap untuk produk dan pesanan
- **🏥 BPJS Integration** - Integrasi dengan layanan kesehatan BPJS
- **🩺 FHIR/SATUSEHAT** - Dukungan standar kesehatan internasional
- **📖 API Documentation** - Swagger/OpenAPI yang interaktif
@@ -69,8 +65,6 @@ api-service/
│ └── repository/ # 💾 Data access (Infrastructure)
├── 📁 tools/ # 🔧 Development tools
│ ├── general/ # 🎯 General generators
│ ├── bpjs/ # 🏥 BPJS specific tools
│ └── satusehat/ # 🩺 SATUSEHAT tools
├── 📁 docs/ # 📚 Documentation
├── 📁 configs/ # ⚙️ Configuration files
└── 📁 scripts/ # 📜 Automation scripts
@@ -119,55 +113,9 @@ go run cmd/api/main.go
| Service | URL | Status |
| :-- | :-- | :-- |
| **API** | http://localhost:8080/api/v1 | ✅ |
| **Swagger** | http://localhost:8080/swagger/index.html | 📖 |
| **Health Check** | http://localhost:8080/api/v1/health | 💚 |
***
## 🔐 Autentikasi
### Login \& Mendapatkan Token
```bash
curl -X POST http://localhost:8080/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{
"username": "admin",
"password": "password"
}'
```
**Response:**
```json
{
"access_token": "eyJhbGciOiJIUzI1NiIs...",
"expires_in": 3600,
"user": {
"id": "123",
"username": "admin",
"role": "admin"
}
}
```
### Menggunakan Token
```bash
curl -X GET http://localhost:8080/api/v1/products \
-H "Authorization: Bearer <your-token>"
```
### Demo Accounts
| Username | Password | Role | Akses |
| :-- | :-- | :-- | :-- |
| `admin` | `password` | Admin | Semua endpoint |
| `user` | `password` | User | Read-only |
| **API** | http://localhost:8084/api/v1 | ✅ |
| **Swagger** | http://localhost:8084/swagger/index.html | 📖 |
| **Health Check** | http://localhost:8084/api/v1/health | 💚 |
***
@@ -178,64 +126,46 @@ curl -X GET http://localhost:8080/api/v1/products \
| Method | Endpoint | Deskripsi |
| :-- | :-- | :-- |
| `POST` | `/api/v1/auth/login` | Login pengguna |
| `POST` | `/api/v1/auth/register` | Registrasi pengguna baru |
| `GET` | `/api/v1/health` | Status kesehatan API |
### 🔒 Protected Endpoints
#### User Management
#### QRIS Management
| Method | Endpoint | Deskripsi |
| :-- | :-- | :-- |
| `GET` | `/api/v1/auth/me` | Profile pengguna |
| `PUT` | `/api/v1/auth/me` | Update profile |
| `GET` | `/api/v1/qris` | List semua QRIS |
| `GET` | `/api/v1/qris/:id` | Get QRIS berdasarkan ID (serial4) |
| `GET` | `/api/v1/qris/ip/:ip` | List semua QRIS berdasarkan IP yang sama |
| `GET` | `/api/v1/qris/stats` | Statistik QRIS |
#### Product Management
| Method | Endpoint | Deskripsi |
| :-- | :-- | :-- |
| `GET` | `/api/v1/products` | List semua produk |
| `POST` | `/api/v1/products` | Buat produk baru |
| `GET` | `/api/v1/products/:id` | Detail produk |
| `PUT` | `/api/v1/products/:id` | Update produk |
| `DELETE` | `/api/v1/products/:id` | Hapus produk |
*Semua hanya menampilkan QRIS yang berstatus aktif (value = 1)
#### Dynamic Query (Advanced)
| Method | Endpoint | Deskripsi |
| :-- | :-- | :-- |
| `GET` | `/api/v1/retribusi/dynamic` | Query dengan filter dinamis |
| `GET` | `/api/v1/qris/dynamic` | Query dengan filter dinamis (Semua column termapping) |
| `GET` | `/api/v1/qris?search=` | Advanced Search ketika tidak tahu column yang dicari (Column sementara yang termapping: posdevice, display_name, ip) |
**Contoh Query:**
```bash
# Filter berdasarkan jenis
GET /api/v1/retribusi/dynamic?filter[Jenis][_eq]=RETRIBUSI PELAYANAN KESEHATAN
# Filter berdasarkan Pos Device
# _eq harus exact value dan case sensitive
GET /api/v1/qris/dynamic?filter[posdevice][_eq]=GRANDPAV
# Filter berdasarkan IP
# _contains bisa tidak exact value dan case insensitive
GET /api/v1/qris/dynamic?filter[ip][_contains]=106
# Kombinasi filter
GET /api/v1/retribusi/dynamic?filter[status][_eq]=active&filter[Tarif][_gt]=100000
GET /api/v1/qris/dynamic?filter[ip][_eq]=10.10.150.160&filter[display_name][_contains]=irul
# Pagination dan sorting
GET /api/v1/retribusi/dynamic?sort=-date_created&limit=10&offset=20
# Default Limit 10 dan Offset 0 jika tidak didefinisikan di dalam link
GET /api/v1/qris/ip/:ip?limit=10&offset=0
```
### 🏥 BPJS Integration
| Method | Endpoint | Deskripsi |
| :-- | :-- | :-- |
| `GET` | `/api/v1/bpjs/peserta/:no` | Data peserta BPJS |
| `GET` | `/api/v1/bpjs/rujukan/:no` | Data rujukan |
### 🩺 SATUSEHAT Integration
| Method | Endpoint | Deskripsi |
| :-- | :-- | :-- |
| `GET` | `/api/v1/satusehat/patient/:id` | Data pasien |
| `POST` | `/api/v1/satusehat/encounter` | Buat encounter baru |
***
## 🛠️ Development
@@ -252,22 +182,6 @@ go run tools/general/generate-handler.go product get post put delete
go run tools/general/generate-handler.go orders get post put delete dynamic search stats
```
**🏥 Generate BPJS Handler**
```bash
# Single service
go run tools/bpjs/generate-bpjs-handler.go reference/peserta get
# Semua service dari config
go run tools/bpjs/generate-handler.go services-config-bpjs.yaml
```
**🩺 Generate SATUSEHAT Handler**
```bash
go run tools/satusehat/generate-satusehat-handler.go services-config-satusehat.yaml patient
```
### Development Commands
@@ -301,16 +215,9 @@ BLUEPRINT_DB_USERNAME=postgres
BLUEPRINT_DB_PASSWORD=postgres
BLUEPRINT_DB_DATABASE=api_service
# JWT
JWT_SECRET=your-super-secret-key-change-in-production
# External APIs
BPJS_BASE_URL=https://api.bpjs-kesehatan.go.id
SATUSEHAT_BASE_URL=https://api.satusehat.kemkes.go.id
# Application
APP_ENV=development
APP_PORT=8080
APP_PORT=8084
LOG_LEVEL=debug
```
@@ -343,7 +250,7 @@ docker build -t api-service:prod .
# Run production container
docker run -d \
--name api-service \
-p 8080:8080 \
-p 8084:8084 \
--env-file .env.prod \
api-service:prod
```
@@ -369,57 +276,30 @@ make build
### 📖 Interactive API Documentation
Kunjungi **Swagger UI** di: http://localhost:8080/swagger/index.html
Kunjungi **Swagger UI** di: http://localhost:8084/swagger/index.html
**Cara menggunakan:**
1. 🔑 Login melalui `/auth/login` endpoint
2. 📋 Copy token dari response
3. 🔓 Klik tombol "Authorize" di Swagger
4. 📝 Masukkan: `Bearer <your-token>`
5. ✅ Test semua endpoint yang tersedia
✅ Test semua endpoint yang tersedia
### 🧪 Testing Examples
**JavaScript/Axios:**
```javascript
// Login dan set token
const auth = await axios.post('/api/v1/auth/login', {
username: 'admin',
password: 'password'
});
axios.defaults.headers.common['Authorization'] =
`Bearer ${auth.data.access_token}`;
// Fetch data
const products = await axios.get('/api/v1/products');
console.log(products.data);
const qris = await axios.get('/api/v1/qris');
console.log(qris.data);
```
**cURL Examples:**
```bash
# Login
TOKEN=$(curl -s -X POST http://localhost:8080/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"password"}' | jq -r '.access_token')
# Use token
curl -H "Authorization: Bearer $TOKEN" \
http://localhost:8080/api/v1/products
```
### 🔍 Health Monitoring
```bash
# Basic health check
curl http://localhost:8080/api/v1/health
curl http://localhost:8084/api/v1/health
# Detailed system info
curl http://localhost:8080/api/v1/health/detailed
curl http://localhost:8084/api/v1/health/detailed
```
**Response:**
@@ -463,12 +343,6 @@ make logs-db
- ✅ Cek permission write di folder `internal/`
- ✅ Verifikasi file `internal/routes/v1/routes.go` exists
**❌ Token Invalid/Expired**
- 🔄 Login ulang untuk mendapatkan token baru
- ⏰ Token expire dalam 1 jam (configurable)
- 📝 Format harus: `Bearer <token>`
**❌ Import Error saat Generate**
- 🧹 Jalankan: `go mod tidy`