add('GET', '/', function() { echo json_encode([ 'status' => 'success', 'message' => 'Saqel API is running in Pure PHP mode!' ]); }); $router->add('GET', '/api/ping', function() { $time_start = microtime(true); // Test DB connection $db = Database::getInstance()->getConnection(); $stmt = $db->query("SELECT 1"); $dbStatus = $stmt ? 'connected' : 'failed'; $time_end = microtime(true); $execution_time = ($time_end - $time_start) * 1000; echo json_encode([ 'status' => 'success', 'message' => 'Saqel Pure PHP Backend is running incredibly fast!', 'database' => $dbStatus, 'execution_time_ms' => round($execution_time, 2) ]); }); // Example route for user login (Mock) $router->add('POST', '/api/auth/login', function() { $data = json_decode(file_get_contents("php://input"), true); // In a real app, query Database here and verify password if (isset($data['email']) && isset($data['password'])) { echo json_encode([ 'access_token' => bin2hex(random_bytes(16)), 'token_type' => 'Bearer', 'user' => [ 'email' => $data['email'], 'role' => 'student' ] ]); } else { header("HTTP/1.0 400 Bad Request"); echo json_encode(['error' => 'Missing email or password']); } }); $router->dispatch($_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI']);