| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- require __DIR__ . '/../vendor/autoload.php';
- $path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
- $file = __DIR__ . $path;
- if (php_sapi_name() === 'cli-server' && is_file($file)) {
- return false;
- }
- if (class_exists(Dotenv\Dotenv::class) && file_exists(__DIR__ . '/../.env')) {
- Dotenv\Dotenv::createImmutable(
- dirname(__DIR__),
- null,
- true
- )->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();
- // Rotas com CORS aplicado
- $app->get('/hmachelloworld', $cors, $authHmac, \Controllers\HelloController::class);
- $app->get('/jwthelloworld', $cors, $authJwt, \Controllers\HelloController::class);
- //Rotas User
- $app->post('/login', $cors, \Controllers\LoginController::class);
- $app->post('/register', $cors, \Controllers\RegisterController::class);
- $app->post('/user/get', $cors, $authJwt, \Controllers\UserGetController::class);
- $app->post('/user/delete', $cors, $authJwt, \Controllers\UserDeleteController::class);
- //Rotas Category
- $app->post('/category/get', $cors, \Controllers\CategoryGetController::class);
- $app->post('/category/create', $cors, $authJwt, \Controllers\CategoryCreateController::class);
- $app->post('/category/delete', $cors, $authJwt, \Controllers\CategoryDeleteController::class);
- $app->post('/category/add-product', $cors, $authJwt, \Controllers\CategoryAddProductController::class);
- //Rotas Product
- $app->post('/product/get', $cors, \Controllers\ProductGetController::class);
- $app->post('/product/create', $cors, $authJwt, \Controllers\ProductCreateController::class);
- $app->post('/product/update', $cors, $authJwt, \Controllers\ProductUpdateController::class);
- $app->post('/product/delete', $cors, $authJwt, \Controllers\ProductDeleteController::class);
- //Rotas Table
- $app->post('/table/get', $cors, $authJwt, \Controllers\TableGetController::class);
- $app->post('/table/create', $cors, $authJwt, \Controllers\TableCreateController::class);
- $app->post('/table/delete', $cors, $authJwt, \Controllers\TableDeleteController::class);
- $app->post('/table/update', $cors, $authJwt, \Controllers\TableUpdateController::class);
- $app->run();
|