Files
d4rkbot/frontend/src/api.js
T
D4rkst3randClaude Opus 4.8 ae5732a61b Setup-Seite: Kanal-Auswahl, Feed-Regeln und Status im Webinterface
- Settings-Tabelle in SQLite; Env-Variablen nur noch Fallback, Änderungen greifen sofort
- /settings (Admin): Devlog-/Commit-Kanal als Dropdown aus allen sichtbaren Textkanälen,
  je mit Test-senden-Button
- Commit-Feed-Regeln: an/aus, Branch-Filter, ignorierte Repos (archiviert wird immer,
  gefiltert wird nur das Posten; ignorierte Repos komplett übersprungen)
- Status-Panel: Bot-Tag, Uptime, Devlog-/Commit-Zahlen, DB-Größe
- API: GET/PUT /api/settings, POST /api/settings/test/:target (alles Admin-only)
- COMMIT_CHANNEL_ID/DEVLOG_CHANNEL_ID in config optional

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 10:21:05 +02:00

26 lines
908 B
JavaScript

// Kleiner Fetch-Wrapper — Cookies (Session) laufen automatisch mit (same-origin)
async function api(path, options = {}) {
const res = await fetch(path, { headers: { Accept: 'application/json' }, ...options });
if (!res.ok) {
const error = new Error(`API ${res.status}`);
error.status = res.status;
throw error;
}
return res.json();
}
export const apiGet = (path) => api(path);
export const apiDelete = (path) => api(path, { method: 'DELETE' });
export const apiPut = (path, body) =>
api(path, {
method: 'PUT',
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
body: JSON.stringify(body),
});
export const apiPost = (path, body = {}) =>
api(path, {
method: 'POST',
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
body: JSON.stringify(body),
});