Initial commit: Mathe-App Phase 1-3

- React+Vite Frontend mit Routing, eigenem fetch-Client (kein axios)
- Express Backend: Auth (JWT), Topics, Tasks, Leaderboard
- PostgreSQL Schema + Seed: 7 Kategorien, 21 Topics, ~25 Aufgaben
- Gamification: XP, Level (100×n^1.5), tägliche Streaks
- docker-compose auf Port 3100 für DS1621
- Alltagsaufgaben: Finanzen, Geometrie, Physik, Informatik, Verkehr, Shopping
This commit is contained in:
rene 2026-04-06 17:24:35 +02:00
commit c8b354ed45
49 changed files with 6127 additions and 0 deletions

View file

@ -0,0 +1,41 @@
const BASE = '/api'
function getToken() {
return localStorage.getItem('token')
}
function headers(extra = {}) {
const h = { 'Content-Type': 'application/json', ...extra }
const token = getToken()
if (token) h['Authorization'] = `Bearer ${token}`
return h
}
async function request(method, path, body) {
const res = await fetch(`${BASE}${path}`, {
method,
headers: headers(),
credentials: 'include',
body: body !== undefined ? JSON.stringify(body) : undefined,
})
const data = await res.json().catch(() => ({}))
if (!res.ok) {
const err = new Error(data.message || `HTTP ${res.status}`)
err.status = res.status
err.data = data
throw err
}
return data
}
const api = {
get: (path) => request('GET', path),
post: (path, body) => request('POST', path, body),
put: (path, body) => request('PUT', path, body),
delete: (path) => request('DELETE', path),
}
export default api