49 lines
1.7 KiB
PHP
49 lines
1.7 KiB
PHP
<?php declare(strict_types=1);
|
|
|
|
use Lewisdale\App\Controllers\FeedController;
|
|
use Lewisdale\App\Controllers\HomeController;
|
|
use Lewisdale\App\Controllers\LoginController;
|
|
use Lewisdale\App\Session\LoginMiddleware;
|
|
use Slim\Routing\RouteCollectorProxy;
|
|
use Slim\Views\TwigMiddleware;
|
|
|
|
ini_set('user_agent', 'Baleen/1.0 (https://baleen.lewisdale.dev)');
|
|
ini_set('session.name', 'sessid');
|
|
ini_set('session.cookie_samesite', 'Lax');
|
|
|
|
require_once __DIR__ . "/dependencies.php";
|
|
|
|
global $container;
|
|
global $app;
|
|
|
|
$dotenv = Dotenv\Dotenv::createImmutable([__DIR__, __DIR__ . "/.."]);
|
|
$dotenv->safeLoad();
|
|
|
|
require_once __DIR__ . "/session.php";
|
|
|
|
$app->add(TwigMiddleware::createFromContainer($app));
|
|
$app->add('csrf');
|
|
|
|
$app->get("/", [HomeController::class, 'get']);
|
|
|
|
$app->group('/feed', function (RouteCollectorProxy $group) use ($app) {
|
|
$group->get('[/]', [FeedController::class, 'get'])->add(LoginMiddleware::class);
|
|
$group->post('[/]', [FeedController::class, 'save'])->add(LoginMiddleware::class);
|
|
|
|
$group->get('/new', [FeedController::class, 'create'])->add(LoginMiddleware::class);
|
|
|
|
$group->get('/{id}', [FeedController::class, 'get_feed']);
|
|
$group->post('/{id}', [FeedController::class, 'save'])->add(LoginMiddleware::class);
|
|
|
|
$group->get('/{id}/delete', [FeedController::class, 'delete'])->add(LoginMiddleware::class);
|
|
$group->get('/{id}/edit', [FeedController::class, 'create'])->add(LoginMiddleware::class);
|
|
});
|
|
|
|
$app->group('/account', function (RouteCollectorProxy $group) use ($app, $container) {
|
|
$group->get('/login', [LoginController::class, 'index']);
|
|
$group->post('/login', [LoginController::class, 'login']);
|
|
});
|
|
|
|
$app->addErrorMiddleware(true, true, true);
|
|
|
|
$app->run(); |