<?php
session_start();
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;

require '../vendor/autoload.php';
require '../class/Db.php';

$configuration = [
    'settings' => [
        'displayErrorDetails' => true,
    ],
];
$c = new \Slim\Container($configuration);
$app = new \Slim\App($c);


//enable cors
$app->options('/{routes:.+}', function ($request, $response, $args) {
    return $response;
});


$app->add(function ($req, $res, $next) {
    $response = $next($req, $res);

    return $response
            ->withHeader('Access-Control-Allow-Origin', '*')
            ->withHeader('Access-Control-Allow-Credentials', 'true')
            ->withHeader('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type, Accept, Origin, Authorization')
            ->withHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS');
});

//add all the routes
require_once('../routes/home.php');
require_once('../routes/user.php');
require_once('../routes/support.php');
require_once('../routes/solicitor.php');
require_once('../routes/barrister.php');
require_once('../routes/client.php');
require_once('../routes/court.php');
require_once('../routes/case.php');
require_once('../routes/note.php');
require_once('../routes/document.php');
require_once('../routes/meeting.php');
require_once('../routes/task.php');
require_once('../routes/form.php');
require_once('../routes/invoice.php');


$app->run();

?>