API endpoints dan integrasi untuk platform "Naik Kelas by Koneksi".
Platform ini mendukung sistem pembelajaran berbasis project untuk program edukasi teknologi Naik Kelas.
🚧 Work in Progress - Documentation akan dilengkapi seiring development
- Endpoint:
POST /demo/lucia/login?/login - Description: Authenticate user dengan username dan password
- Status: ✅ Implemented
- Endpoint:
POST /demo/lucia/login?/register - Description: Register user baru
- Status: ✅ Implemented
- Endpoint:
POST /demo/lucia?/logout - Description: Logout user dan invalidate session
- Status: ✅ Implemented
- Endpoint:
GET /api/notifications/stream - Auth: Required (session cookie via Lucia)
- Description: Server-Sent Events stream untuk real-time notification updates
- Status: ✅ Implemented
Response: text/event-stream
Immediately sends initial unread count on connect, then polls every 8 seconds for new notifications. Heartbeat sent every 25 seconds to keep the connection alive.
Event payload (JSON in data: field):
{
"unreadCount": 3,
"newNotifications": [
{
"id": "notif_abc123",
"type": "course_update",
"title": "Modul baru tersedia",
"message": "Modul 3 sudah bisa diakses",
"link": "/app/courses/123"
}
]
}newNotificationshanya ada jika ada notifikasi baru sejak koneksi terakhir- Heartbeat dikirim sebagai SSE comment (
: heartbeat) — tidak perlu diproses client
Error responses:
401 Unauthorized— user tidak terautentikasi
GET /api/users- Get all usersGET /api/users/:id- Get user by IDPUT /api/users/:id- Update userDELETE /api/users/:id- Delete user
GET /api/courses- Get all coursesGET /api/courses/:id- Get course by IDPOST /api/courses- Create new coursePUT /api/courses/:id- Update courseDELETE /api/courses/:id- Delete course
CREATE TABLE user (
id TEXT PRIMARY KEY,
username TEXT NOT NULL UNIQUE,
password_hash TEXT NOT NULL,
age INTEGER
);CREATE TABLE session (
id TEXT PRIMARY KEY,
user_id TEXT NOT NULL,
expires_at INTEGER NOT NULL,
FOREIGN KEY (user_id) REFERENCES user(id)
);- User submits login form
- Server validates credentials
- Server creates session
- Client receives cookie
- Subsequent requests include session cookie
Last Updated: 2025-01-23