-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.php
More file actions
46 lines (36 loc) · 1.28 KB
/
Copy pathapp.php
File metadata and controls
46 lines (36 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
use App\Services\Database\SQL;
use App\Services\Router\Request;
use App\Services\Router\Response;
use App\Services\Router\Router;
// things go bomboclat if this isnt here bcs preflight cors
header("Access-Control-Allow-Origin: *", true);
header("Access-Control-Allow-Methods: GET, POST, OPTIONS", true);
header("Access-Control-Allow-Headers: Content-Type, Authorization", true);
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
http_response_code(200);
exit();
}
// Configure router
$router = new Router();
require_once __DIR__ . '/routes/categoryRoutes.php';
require_once __DIR__ . '/routes/tagRoutes.php';
require_once __DIR__ . '/routes/assetRoutes.php';
require_once __DIR__ . '/routes/fileRoutes.php';
require_once __DIR__ . '/routes/userRoutes.php';
require_once __DIR__ . '/routes/adminRoutes.php';
$router->AddGET('/', function (Request $req, Response $res): void {
$res->SetText('Modelab API');
});
$router->AddPOST('/health', function (Request $req, Response $res): void {
$dbActive = SQL::MiscCheckStatus();
$res->SetJSON([
'health' => [
'timestamp' => time(),
'services' => ['database' => $dbActive],
'version' => '1.0'
]
]);
});
// Start the app
$router->DispatchRequest(Request::GetServerRequestURI());