<?php
declare(strict_types=1);

require_once __DIR__ . '/app/Helpers/bootstrap.php';

try {
    $users = (int)db()->query('SELECT COUNT(*) FROM ' . table('users'))->fetchColumn();
    if ($users === 0) {
        header('Location: /setup.php');
    } else {
        header('Location: /dashboard.php');
    }
} catch (Throwable $exception) {
    http_response_code(500);
    echo '<h1>TripTale</h1><p>Die Datenbankverbindung konnte nicht hergestellt werden. Bitte prüfe die Zugangsdaten in <code>config/config.php</code>.</p>';
}
