<?php

declare(strict_types=1);

use Slim\App;
use App\Factories\ServiceFactory;
use App\Factories\PostControllerFactory;

/**
 * @param App $app
 * @return void
 */
return function (App $app): void {
    // Créer services (centralisé)
    $services = \App\Factories\ServiceFactory::createServices();

    // Créer controller via sa factory
    $controller = PostControllerFactory::create($services);

    $app->get('/', [$controller, 'index']);
    $app->get('/admin', [$controller, 'admin']);
    $app->get('/admin/edit/{id}', [$controller, 'form']);
    $app->post('/admin/create', [$controller, 'create']);
    $app->post('/admin/edit/{id}', [$controller, 'update']);
    $app->post('/admin/delete/{id}', [$controller, 'delete']);
};
