36 lines
903 B
PHP
36 lines
903 B
PHP
<?php
|
|
require __DIR__ . '/../vendor/autoload.php';
|
|
|
|
use Slim\Factory\AppFactory;
|
|
|
|
require __DIR__ . '/../src/config.php';
|
|
require __DIR__ . '/../src/db.php';
|
|
require __DIR__ . '/../src/jwt.php';
|
|
|
|
$app = AppFactory::create();
|
|
|
|
// CORS for dev
|
|
$app->add(function ($request, $handler) {
|
|
$response = $handler->handle($request);
|
|
return $response
|
|
->withHeader('Access-Control-Allow-Origin', '*')
|
|
->withHeader('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type, Accept, Origin, Authorization')
|
|
->withHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS');
|
|
});
|
|
|
|
$app->addRoutingMiddleware();
|
|
$app->addErrorMiddleware(true, true, true);
|
|
|
|
// Options handler
|
|
$app->options('/{routes:.+}', function ($request, $response) {
|
|
return $response;
|
|
});
|
|
|
|
// Init DB
|
|
getDb();
|
|
|
|
// Register routes
|
|
require __DIR__ . '/../src/routes.php';
|
|
|
|
$app->run();
|