2024-05-16 01:42:24 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Slovocast;
|
|
|
|
|
|
|
|
use Slim\App;
|
2024-05-16 02:15:24 +00:00
|
|
|
use Slovocast\Controller\HomePage;
|
2024-06-27 01:10:48 +00:00
|
|
|
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;
|
2024-05-16 01:42:24 +00:00
|
|
|
|
|
|
|
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-05-16 01:42:24 +00:00
|
|
|
{
|
2024-05-16 02:15:24 +00:00
|
|
|
$app->get('/', HomePage::class);
|
2024-06-27 01:10:48 +00:00
|
|
|
$app->get('/healthcheck', HealthCheck::class);
|
2024-05-16 01:42:24 +00:00
|
|
|
// User Routes
|
|
|
|
self::users($app);
|
2024-07-18 02:05:42 +00:00
|
|
|
self::dashboard($app);
|
2024-05-16 01:42:24 +00:00
|
|
|
}
|
|
|
|
|
2024-06-27 23:50:42 +00:00
|
|
|
/**
|
|
|
|
* @param App $app Instantiated Application
|
|
|
|
*/
|
2024-05-16 01:42:24 +00:00
|
|
|
protected static function users(App $app): void
|
|
|
|
{
|
2024-06-17 00:44:12 +00:00
|
|
|
$app->get('/users/register', RegisterUserPage::class)
|
|
|
|
->setName('user-register-page');
|
2024-06-16 01:50:40 +00:00
|
|
|
$app->post('/users/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');
|
2024-06-17 01:47:44 +00:00
|
|
|
$app->post('/login', LoginUserAction::class)
|
|
|
|
->setName('user-login-action');
|
2024-07-18 02:05:42 +00:00
|
|
|
}
|
2024-06-27 23:50:42 +00:00
|
|
|
|
2024-10-10 01:20:52 +00:00
|
|
|
/**
|
|
|
|
* @param App $app Instance of the application
|
|
|
|
*/
|
2024-07-18 02:05:42 +00:00
|
|
|
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');
|
2024-05-16 01:42:24 +00:00
|
|
|
}
|
|
|
|
}
|