Skip to content

Commit 8ffd764

Browse files
composer update and minor changes
1 parent 06a5eb9 commit 8ffd764

File tree

8 files changed

+3626
-3521
lines changed

8 files changed

+3626
-3521
lines changed

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"minimum-stability": "dev",
2424
"prefer-stable": true,
2525
"require": {
26-
"php": "^7.4",
26+
"php": "^7.4 || ^8.0",
27+
"composer/composer": "1.10.22",
2728
"firebase/php-jwt": "^5.0",
2829
"monolog/monolog": "^2.0@dev",
2930
"palanik/corsslim": "dev-slim3",
@@ -34,7 +35,7 @@
3435
},
3536
"require-dev": {
3637
"nunomaduro/phpinsights": "^1.14",
37-
"pestphp/pest": "^0.1.5",
38+
"pestphp/pest": "^1.7",
3839
"phpstan/phpstan": "^0.12",
3940
"phpunit/phpunit": "^9.0",
4041
"vimeo/psalm": "^3.15"

composer.lock

Lines changed: 3608 additions & 3512 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/App/Dependencies.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@
4343

4444
$container['notFoundHandler'] = static function () {
4545
return static function ($request, $response): void {
46-
throw new \Exception('Route Not Found.', 404);
46+
throw new \App\Exception\NotFoundException('Route Not Found.', 404);
4747
};
4848
};

src/Controller/DefaultController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
final class DefaultController extends BaseController
1111
{
12-
public const API_VERSION = '1.7.0';
12+
public const API_VERSION = '1.8.0';
1313

1414
public function getHelp(Request $request, Response $response): Response
1515
{
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44

55
namespace App\Exception;
66

7-
final class Auth extends Base
7+
final class AuthException extends Base
88
{
99
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Exception;
6+
7+
final class NotFoundException extends Base
8+
{
9+
}

src/Middleware/Auth.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ public function __invoke(
1818
): ResponseInterface {
1919
$jwtHeader = $request->getHeaderLine('Authorization');
2020
if (!$jwtHeader) {
21-
throw new \App\Exception\Auth('JWT Token required.', 400);
21+
throw new \App\Exception\AuthException('JWT Token required.', 400);
2222
}
2323
$jwt = explode('Bearer ', $jwtHeader);
2424
if (!isset($jwt[1])) {
25-
throw new \App\Exception\Auth('JWT Token invalid.', 400);
25+
throw new \App\Exception\AuthException('JWT Token invalid.', 400);
2626
}
2727
$decoded = $this->checkToken($jwt[1]);
2828
$object = (array) $request->getParsedBody();

src/Middleware/Base.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace App\Middleware;
66

7-
use App\Exception\Auth;
87
use Firebase\JWT\JWT;
98

109
abstract class Base
@@ -14,7 +13,7 @@ protected function checkToken(string $token): object
1413
try {
1514
return JWT::decode($token, $_SERVER['SECRET_KEY'], ['HS256']);
1615
} catch (\UnexpectedValueException $exception) {
17-
throw new Auth('Forbidden: you are not authorized.', 403);
16+
throw new \App\Exception\AuthException('Forbidden: you are not authorized.', 403);
1817
}
1918
}
2019
}

0 commit comments

Comments
 (0)