You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.2 KiB
38 lines
1.2 KiB
<?php
|
|
|
|
require "../../config.php";
|
|
require "../../vendor/autoload.php";
|
|
require "../../sql/database.php";
|
|
require "../utils.php";
|
|
|
|
use IQBall\Api\API;
|
|
use IQBall\Api\Controller\APIAuthController;
|
|
use IQBall\Api\Controller\APITacticController;
|
|
use IQBall\Core\Action;
|
|
use IQBall\Core\Connection;
|
|
use IQBall\Core\Data\Account;
|
|
use IQBall\Core\Gateway\AccountGateway;
|
|
use IQBall\Core\Gateway\TacticInfoGateway;
|
|
use IQBall\Core\Model\AuthModel;
|
|
use IQBall\Core\Model\TacticModel;
|
|
|
|
function getTacticController(): APITacticController {
|
|
return new APITacticController(new TacticModel(new TacticInfoGateway(new Connection(get_database()))));
|
|
}
|
|
|
|
function getAuthController(): APIAuthController {
|
|
return new APIAuthController(new AuthModel(new AccountGateway(new Connection(get_database()))));
|
|
}
|
|
|
|
function getRoutes(): AltoRouter {
|
|
$router = new AltoRouter();
|
|
$router->setBasePath(get_public_path() . "/api");
|
|
|
|
$router->map("POST", "/tactic/[i:id]/edit/name", Action::auth(fn(int $id, Account $acc) => getTacticController()->updateName($id, $acc)));
|
|
$router->map("POST", "/auth", Action::noAuth(fn() => getAuthController()->authorize()));
|
|
|
|
return $router;
|
|
}
|
|
|
|
Api::render(API::handleMatch(getRoutes()->match()));
|