mirror of
https://codeberg.org/demostf/api.git
synced 2026-06-03 18:04:08 +02:00
fix type errors
This commit is contained in:
parent
3f9e613e77
commit
3c3b23d1a3
3 changed files with 17 additions and 1 deletions
|
|
@ -68,6 +68,7 @@ class Demo implements JsonSerializable {
|
||||||
$this->backend = $backend;
|
$this->backend = $backend;
|
||||||
$this->path = $path;
|
$this->path = $path;
|
||||||
$this->players = [];
|
$this->players = [];
|
||||||
|
$this->uploaderUser = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getId(): int {
|
public function getId(): int {
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ Flight::route('/auth/handle/@token', [$authController, 'handle']);
|
||||||
Flight::route('/auth/login/@token', [$authController, 'login']);
|
Flight::route('/auth/login/@token', [$authController, 'login']);
|
||||||
Flight::route('/auth/logout/@token', [$authController, 'logout']);
|
Flight::route('/auth/logout/@token', [$authController, 'logout']);
|
||||||
|
|
||||||
Flight::map('error', function (\Exception $ex) {
|
Flight::map('error', function (\Throwable $ex) {
|
||||||
$code = 500;
|
$code = 500;
|
||||||
if ($ex instanceof InvalidKeyException) {
|
if ($ex instanceof InvalidKeyException) {
|
||||||
$code = 401;
|
$code = 401;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,10 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Demostf\API;
|
namespace Demostf\API;
|
||||||
|
|
||||||
|
use Demostf\API\Error\InvalidHashException;
|
||||||
|
use Demostf\API\Error\InvalidKeyException;
|
||||||
use Flight;
|
use Flight;
|
||||||
|
use flight\net\Response;
|
||||||
|
|
||||||
/** @var Container $container */
|
/** @var Container $container */
|
||||||
$container = require __DIR__ . '/init.php';
|
$container = require __DIR__ . '/init.php';
|
||||||
|
|
@ -24,4 +27,16 @@ Flight::route('/*', function () {
|
||||||
Flight::route('/upload', [$uploadController, 'upload']);
|
Flight::route('/upload', [$uploadController, 'upload']);
|
||||||
Flight::route('/do_upload', [$uploadController, 'upload']);
|
Flight::route('/do_upload', [$uploadController, 'upload']);
|
||||||
|
|
||||||
|
Flight::map('error', function (\Throwable $ex) {
|
||||||
|
$code = 500;
|
||||||
|
if ($ex instanceof InvalidKeyException) {
|
||||||
|
$code = 401;
|
||||||
|
} elseif ($ex instanceof InvalidHashException) {
|
||||||
|
$code = 412;
|
||||||
|
}
|
||||||
|
/** @var Response $response */
|
||||||
|
$response = Flight::response()->status($code);
|
||||||
|
$response->write($ex->getMessage())->send();
|
||||||
|
});
|
||||||
|
|
||||||
Flight::start();
|
Flight::start();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue