Initial setup, not working yet

This commit is contained in:
2026-06-12 15:08:50 +03:00
parent 2aba4b03a4
commit a467754d6c
37 changed files with 1211 additions and 4 deletions

35
frontend/api/client.php Normal file
View File

@@ -0,0 +1,35 @@
<?php
require_once __DIR__ . "/config.php";
function api_request($method, $endpoint, $data = null, $token = null) {
$ch = curl_init(API_BASE . $endpoint);
$headers = [
"Content-Type: application/json"
];
if ($token) {
$headers[] = "Authorization: Bearer " . $token;
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
if ($data !== null) {
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
}
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
if ($response === false) {
die(curl_error($ch));
}
curl_close($ch);
return json_decode($response, true);
}

3
frontend/api/config.php Normal file
View File

@@ -0,0 +1,3 @@
<?php
define("API_BASE", "http://localhost:8080");