Skip to content

Commit

Permalink
Parking Functionality in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
DevSaad02 committed Mar 4, 2025
1 parent 8508c28 commit 9015b90
Show file tree
Hide file tree
Showing 13 changed files with 896 additions and 39 deletions.
9 changes: 9 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
DRIVER=mysql
DB_HOST=127.0.0.1
DB=ticketing_system
DB_USERNAME=root
DB_PASS=admin

JWT_SECRET='3X@mPl3-K3y!@#67hJG8sdf9'
JWT_ISSUER=http://localhost:8000
JWT_EXPIRY=3600 # Expiry time in seconds (1 hour)
25 changes: 18 additions & 7 deletions app/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use Slim\App;
use App\Helpers\JwtHelper;
use App\Middleware\JwtMiddleware;
use App\Controllers\ParkingController;
use App\Controllers\Auth\AuthController;
use Slim\Exception\HttpNotFoundException;
use App\Application\Actions\User\ViewUserAction;
Expand All @@ -13,13 +15,9 @@
use Slim\Interfaces\RouteCollectorProxyInterface as Group;

return function (App $app) {

$app->options('/{routes:.*}', function (Request $request, Response $response) {
// CORS Pre-Flight OPTIONS Request Handler
return $response
->withHeader('Access-Control-Allow-Origin', 'http://localhost:3000')
->withHeader('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type, Accept, Origin, Authorization')
->withHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS')
->withHeader('Access-Control-Allow-Credentials', 'true');
return $response;
});

$app->get('/', function (Request $request, Response $response) {
Expand Down Expand Up @@ -48,7 +46,20 @@

return $next($request, $response);
};
$app->post('/register', [AuthController::class, 'register']);
$app->group('/auth', function (Group $group) {

$group->post('/register', [AuthController::class, 'register']);
$group->post('/login', [AuthController::class, 'login']);
});

$app->group('/parking', function (Group $group) {

$group->get('', [ParkingController::class, 'getParkings']);
$group->post('', [ParkingController::class, 'addParking']);
$group->get('/{id}', [ParkingController::class, 'getParkingById']);
$group->put('/{id}', [ParkingController::class, 'updateParking']);
$group->delete('/{id}', [ParkingController::class, 'deleteParking']);
})->add(JwtMiddleware::class);

/**
* Catch-all route to serve a 404 Not Found page if none of the routes match
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"monolog/monolog": "^2.8",
"php-di/php-di": "^6.4",
"slim/psr7": "^1.5",
"slim/slim": "^4.10"
"slim/slim": "^4.10",
"vlucas/phpdotenv": "^5.6"
},
"require-dev": {
"jangregor/phpstan-prophecy": "^1.0.0",
Expand Down
Loading

0 comments on commit 9015b90

Please sign in to comment.