Files
mystuff_backend/api/config.php
Lars Behrends e38a6e1f7b Add strict types and type hints across API
Apply strict_types and extensive type declarations throughout the API and models, improving type safety and error handling. Key changes: add declare(strict_types=1) to many files; convert properties, method parameters and return values to typed signatures (PDO, arrays, ints, strings, bools, nullables); switch exception handling to Throwable in index and Router; improve Router, controllers and model method signatures and nullability handling; refine file/image serving security checks and headers in ImageController; strengthen Database typing and initialization methods; return explicit types from BaseModel CRUD helpers and counting; update Media/Cast/Adult/Game/Console/Settings controllers and models to use typed methods, better validation, and clearer update/create return types. Also add AGENTS.md (agent skills index), update README with Swagger/OpenAPI usage instructions, and add /.windsurf to .gitignore. These changes aim to harden runtime correctness, make intended contracts explicit, and prepare the codebase for easier maintenance and static analysis.
2026-04-16 16:40:31 +02:00

43 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
// Konfiguration
// Docker-Umgebungsvariablen oder Standardwerte
define('DB_HOST', getenv('DB_HOST') ?: 'mariadb');
define('DB_NAME', getenv('DB_NAME') ?: 'kyoo');
define('DB_USER', getenv('DB_USER') ?: 'kyoo_user');
define('DB_PASS', getenv('DB_PASS') ?: 'kyoo_password');
define('API_BASE', '/api');
// API Logging Konfiguration
define('API_LOGGING_ENABLED', getenv('API_LOGGING_ENABLED') === 'true' || false); // Standardmäßig aktiviert zum Testen
define('API_LOG_FILE', '/var/www/html/logs/api.log');
// PHP Error Logging Konfiguration
define('PHP_ERROR_LOG_FILE', '/var/www/html/logs/php_error.log');
// Hilfsfunktion für cleanname Generierung
function generateCleanName(string $name): string {
// Kleinbuchstaben, nur alphanumerische Zeichen und Bindestriche
$clean = strtolower($name);
// Sonderzeichen durch Bindestriche ersetzen
$clean = preg_replace('/[^a-z0-9]+/', '-', $clean);
// Bindestriche am Anfang und Ende entfernen
$clean = trim($clean, '-');
// Mehrere Bindestriche durch einen ersetzen
$clean = preg_replace('/-+/', '-', $clean);
return $clean;
}
// CORS-Header
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type');
// OPTIONS-Request behandeln
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
http_response_code(200);
exit;
}