<?php

use MintyPHP\Router;

$routesFile = __DIR__ . '/routes.php';
$routeDefinitions = defined('APP_ROUTE_DEFINITIONS') ? APP_ROUTE_DEFINITIONS : [];
if (!is_array($routeDefinitions) || !$routeDefinitions) {
    $routeDefinitions = is_file($routesFile) ? include $routesFile : [];
}

if (is_array($routeDefinitions)) {
    foreach ($routeDefinitions as $route) {
        $path = trim((string) ($route['path'] ?? ''));
        $target = trim((string) ($route['target'] ?? ''));
        if ($path !== '' && $target !== '') {
            Router::addRoute($path, $target);
        }
    }
}
