|
|
|
@ -8,6 +8,7 @@ require "../../src/index-utils.php";
|
|
|
|
|
use IQBall\Api\API;
|
|
|
|
|
use IQBall\Api\Controller\APIAuthController;
|
|
|
|
|
use IQBall\Api\Controller\APITacticController;
|
|
|
|
|
use IQBall\Api\Controller\APIUserController;
|
|
|
|
|
use IQBall\App\Session\PhpSessionHandle;
|
|
|
|
|
use IQBall\Core\Action;
|
|
|
|
|
use IQBall\Core\Connection;
|
|
|
|
@ -25,6 +26,10 @@ function getAuthController(): APIAuthController {
|
|
|
|
|
return new APIAuthController(new AuthModel(new AccountGateway(new Connection(get_database()))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getAPIUserController() : APIUserController {
|
|
|
|
|
return new APIUserController(new AuthModel(new AccountGateway(new Connection(get_database()))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getRoutes(): AltoRouter {
|
|
|
|
|
$router = new AltoRouter();
|
|
|
|
|
$router->setBasePath(get_public_path(__DIR__));
|
|
|
|
@ -32,7 +37,7 @@ function getRoutes(): AltoRouter {
|
|
|
|
|
$router->map("POST", "/auth", Action::noAuth(fn() => getAuthController()->authorize()));
|
|
|
|
|
$router->map("POST", "/tactic/[i:id]/edit/name", Action::auth(fn(int $id, Account $acc) => getTacticController()->updateName($id, $acc)));
|
|
|
|
|
$router->map("POST", "/tactic/[i:id]/save", Action::auth(fn(int $id, Account $acc) => getTacticController()->saveContent($id, $acc)));
|
|
|
|
|
$router->map("POST", "/user/username/[name]", Action::auth(fn(string $username, Account $acc) => getUserController()->))
|
|
|
|
|
$router->map("POST", "/user/username", Action::auth(fn(Account $acc) => getAPIUserController()->changeUsername($acc)));
|
|
|
|
|
return $router;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|