safeLoad(); } error_reporting(E_ALL); ini_set('display_errors', 1); // Para depuração ini_set('display_startup_errors', 1); use FrameworkX\App; use Middlewares\HmacAuthMiddleware; use Middlewares\JWTAuthMiddleware; use Middlewares\CorsControl; use Psr\Http\Message\ServerRequestInterface; use React\Http\Message\Response; $app = new App(); // Instancia os middlewares $authHmac = new HmacAuthMiddleware(); $authJwt = new JWTAuthMiddleware(); $cors = new CorsControl(); // Função para envolver rotas com CORS $withCors = function ($handler) use ($cors) { return function (ServerRequestInterface $request) use ($handler, $cors) { return $cors($request, $handler); }; }; // Rotas com CORS aplicado $app->get('/hmachelloworld', $withCors($authHmac), \Controllers\HelloController::class); $app->get('/jwthelloworld', $withCors($authJwt), \Controllers\HelloController::class); //Rotas User $app->post('/login', $withCors(\Controllers\LoginController::class)); $app->post('/register', $withCors(\Controllers\RegisterController::class)); //Rotas Category $app->post('/category/get', $withCors(\Controllers\CategoryGetController::class) ); $app->post('/category/create', $withCors(\Controllers\CategoryCreateController::class) ); $app->post('/category/delete', $withCors(\Controllers\CategoryDeleteController::class) ); $app->post('/category/add-product', $withCors(\Controllers\CategoryAddProductController::class) ); //Rotas Product $app->get('/product', $withCors($authHmac), \Controllers\ProductController::class); $app->post('/product', $withCors($authHmac), \Controllers\ProductController::class); $app->run();