<?php

// ─── CORS & JSON Headers ─────────────────────────────────────────────────────
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
header("Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With");
header("Content-Type: application/json; charset=UTF-8");

// Handle preflight OPTIONS request
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
    http_response_code(200);
    exit();
}

// ─── Autoload Utils & Config ─────────────────────────────────────────────────
define('BASE_PATH', __DIR__);

require_once BASE_PATH . '/utils/response.php';
require_once BASE_PATH . '/config/database.php';
require_once BASE_PATH . '/config/razorpay.php';

// ─── Load Controllers ─────────────────────────────────────────────────────────
require_once BASE_PATH . '/controllers/AuthController.php';
require_once BASE_PATH . '/controllers/ProductController.php';
require_once BASE_PATH . '/controllers/CartController.php';
require_once BASE_PATH . '/controllers/OrderController.php';
require_once BASE_PATH . '/controllers/VerificationController.php';
require_once BASE_PATH . '/controllers/WishlistController.php';
require_once BASE_PATH . '/controllers/RentalController.php';
require_once BASE_PATH . '/controllers/AddressController.php';
require_once BASE_PATH . '/controllers/UserController.php';
require_once BASE_PATH . '/controllers/UnblockController.php';
require_once BASE_PATH . '/services/MailService.php';


// ─── Route Dispatcher ────────────────────────────────────────────────────────
require_once BASE_PATH . '/routes/api.php';
