Documentation untuk API endpoints CMS Kiryuu.
/api/cms/loginLogin ke admin panel.
Request Body:
{
"username": "admin",
"password": "admin123"
}
Success Response (200):
{
"success": true,
"message": "Login berhasil"
}
Error Response (401):
{
"success": false,
"message": "Username atau password salah"
}
Cookies Set:
admin_session: Session token (HttpOnly, 24 hours)/api/cms/logoutLogout dari admin panel.
Success Response (200):
{
"success": true,
"message": "Logout berhasil"
}
Cookies Cleared:
admin_session/api/cms/validateValidate current session.
Success Response (200):
{
"authenticated": true
}
or
{
"authenticated": false
}
/api/cms/configGet current site configuration.
Authentication Required: Yes (Cookie: admin_session)
Success Response (200):
{
"success": true,
"data": {
"website": "https://kiryuu.io",
"title": "Kiryuu ID",
"seoTitle": "Kiryuu ID - Baca Komik...",
"description": "...",
"hero": {
"title": "Kiryuu ID",
"text": "Baca Komik...",
"image": {
"src": "/assets/images/logo-kiryuu.avif",
"alt": "..."
}
},
"about": {
"text": "..."
},
"socialLinks": [
{
"text": "Facebook",
"href": "https://facebook.com/..."
}
],
"keywords": {
"text": "..."
}
}
}
Error Response (401):
{
"success": false,
"message": "Unauthorized"
}
/api/cms/configUpdate site configuration.
Authentication Required: Yes (Cookie: admin_session)
Request Body:
{
"config": {
"website": "https://kiryuu.io",
"title": "New Title",
"seoTitle": "New SEO Title",
"description": "New description",
"hero": {
"title": "New Hero Title",
"text": "New hero text",
"image": {
"src": "/path/to/image.jpg",
"alt": "Image alt text"
}
},
"about": {
"text": "New about text"
},
"socialLinks": [
{
"text": "Platform Name",
"href": "https://..."
}
],
"keywords": {
"text": "keyword1, keyword2"
},
"websiteManga": "https://...",
"recentPostLimit": 3
}
}
Success Response (200):
{
"success": true,
"message": "Konfigurasi berhasil disimpan"
}
Error Response (401):
{
"success": false,
"message": "Unauthorized"
}
Error Response (500):
{
"success": false,
"message": "Gagal menyimpan konfigurasi"
}
// Login
const login = async (username, password) => {
const response = await fetch('/api/cms/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ username, password }),
});
return await response.json();
};
// Get Config
const getConfig = async () => {
const response = await fetch('/api/cms/config');
return await response.json();
};
// Update Config
const updateConfig = async (config) => {
const response = await fetch('/api/cms/config', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ config }),
});
return await response.json();
};
// Logout
const logout = async () => {
const response = await fetch('/api/cms/logout', {
method: 'POST',
});
return await response.json();
};
# Login
curl -X POST http://localhost:4321/api/cms/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"admin123"}' \
-c cookies.txt
# Get Config (with cookie)
curl http://localhost:4321/api/cms/config \
-b cookies.txt
# Update Config (with cookie)
curl -X POST http://localhost:4321/api/cms/config \
-H "Content-Type: application/json" \
-b cookies.txt \
-d '{"config":{...}}'
# Logout (with cookie)
curl -X POST http://localhost:4321/api/cms/logout \
-b cookies.txt
All endpoints return JSON responses with the following structure:
type APIResponse = {
success: boolean;
message?: string;
data?: any;
};
HTTP Status Codes:
200: Success401: Unauthorized (invalid/missing credentials)500: Server ErrorFor more information, see CMS_README.md