feat: PHP API foundation - router, config, helpers, SM-2 algorithm

Dieser Commit ist enthalten in:
hafroese 2026-04-02 23:05:27 +02:00
Ursprung 9f942a0e56
Commit 581888e142
4 geänderte Dateien mit 152 neuen und 0 gelöschten Zeilen

42
edu/api/index.php Normale Datei
Datei anzeigen

@ -0,0 +1,42 @@
<?php
require_once __DIR__ . '/config.php';
require_once __DIR__ . '/helpers.php';
// Parse: /api/decks/omnis-commands -> ['decks', 'omnis-commands']
$request_uri = $_SERVER['REQUEST_URI'];
$path = parse_url($request_uri, PHP_URL_PATH);
$path = preg_replace('#^/api/?#', '', $path);
$path = trim($path, '/');
$segments = $path ? explode('/', $path) : [];
$resource = $segments[0] ?? '';
switch ($resource) {
case 'login':
case 'logout':
case 'me':
require __DIR__ . '/auth.php';
break;
case 'decks':
require __DIR__ . '/decks.php';
break;
case 'cards':
require __DIR__ . '/cards.php';
break;
case 'tutorials':
require __DIR__ . '/tutorials.php';
break;
case 'quiz':
require __DIR__ . '/quiz.php';
break;
case 'cheatsheets':
require __DIR__ . '/cheatsheets.php';
break;
case 'dashboard':
require __DIR__ . '/dashboard.php';
break;
case 'admin':
require __DIR__ . '/admin.php';
break;
default:
json_error('Unbekannter Endpunkt', 404);
}