* When a page is requested, the Bootstrap will process the request and call the
 * appropriate controller which will give the user the page they want.
 */
require 'config.php';
require __DIR__ . '/../vendor/autoload.php';
// GrandTraining autoloader
require PATH_LIBRARIES . 'slaymaster3000/airbase-php/vendor/autoload.php';
// AirBase autoloader
use AirBase\AirBase;
use AirBase\Session;
use AirBase\Bootstrap;
use AirBase\PageNotFoundException;
use AirBase\NotLoggedInException;
use AirBase\NotLoggedOutException;
// init the lib library
AirBase::init();
AirBase::setIsLoggedInFunction(function () {
    return Session::get('user_id') > 0;
});
try {
    Session::start();
    // start a session
    $bootstrap = new Bootstrap(NAMESPACE_CONTROLLERS, PATH_CONTROLLERS, 'url');
    // process the request
} catch (PageNotFoundException $e) {
    require PATH_ERROR_PAGES . '404.php';
    exit;
} catch (NotLoggedInException $e) {
    header('location: ' . URL_LOGIN);
    // by default, redirect the user to the login page
    exit;