<?php

use BBRouter\RouteCollection as RouteCollection;
use DDLWrapper\Wrapper as Wrapper;

RouteCollection::add('CLI', 'sanity/install', function() {
    include_once 'classes/Migrator.class.php';

    global $DB;
    Wrapper::set_driver($DB);

    Migrator::getInstance()->execute_plan();

    Wrapper::commit();
})->middleware_ignore('auth');


RouteCollection::add('*', '*', function() {
    global $ROUTE;
    //App need to be installed
    if (!is_file(DIR_CONFIG . 'modules.ini')) {
        $ROUTE->do_block()->set_http_error(500);
    }
}, -19)->do_ignore()->middleware_ignore('auth');