slovocast/app/src/Routes.php

58 lines
1.6 KiB
PHP
Raw Normal View History

<?php
namespace Slovocast;
use Slim\App;
use Slovocast\Controller\HomePage;
use Slovocast\Controller\HealthCheck;
2024-06-27 23:50:42 +00:00
use Slovocast\Controller\DashboardPage;
use Slovocast\Controller\User\RegisterUserPage;
use Slovocast\Controller\User\RegisterUserAction;
use Slovocast\Controller\User\LoginUserPage;
use Slovocast\Controller\User\LoginUserAction;
use Slovocast\Middleware\VerifyPasswordMiddleware;
use Slovocast\Middleware\AuthenticatedMiddleware;
class Routes
{
2024-06-27 23:50:42 +00:00
/**
* @param App $app Instantiated Application
* @return void
*/
2024-07-18 01:32:25 +00:00
public static function setup(App $app): void
{
2024-11-07 02:50:14 +00:00
$app->get('/[home]', HomePage::class);
$app->get('/healthcheck', HealthCheck::class);
// User Routes
self::users($app);
self::dashboard($app);
}
2024-06-27 23:50:42 +00:00
/**
* @param App $app Instantiated Application
*/
protected static function users(App $app): void
{
$app->get('/register', RegisterUserPage::class)
2024-06-17 00:44:12 +00:00
->setName('user-register-page');
$app->post('/register', RegisterUserAction::class)
2024-06-17 00:44:12 +00:00
->add(VerifyPasswordMiddleware::class)
->setName('user-register-action');
$app->get('/login', LoginUserPage::class)
->setName('user-login-page');
$app->post('/login', LoginUserAction::class)
->setName('user-login-action');
}
2024-06-27 23:50:42 +00:00
/**
* @param App $app Instance of the application
*/
protected static function dashboard(App $app): void
{
2024-06-27 23:50:42 +00:00
$app->get('/dashboard', DashboardPage::class)
->add(AuthenticatedMiddleware::class)
->setName('user-dashboard');
}
}