From 8c03eed484557c9fb2055d4808c7d41dcea71f86 Mon Sep 17 00:00:00 2001 From: zemion Date: Fri, 19 Sep 2025 21:39:52 +0200 Subject: [PATCH] first working draft --- public/api-proxy.php | 20 ++++++++++++++------ example.html => public/example.html | 14 ++++++++++---- public/js/calco2lato.js | 8 ++++---- src/.env | 2 ++ src/Calco2latoApiClient.php | 10 +++++----- start.bat | 4 ++++ 6 files changed, 39 insertions(+), 19 deletions(-) rename example.html => public/example.html (66%) create mode 100644 src/.env create mode 100644 start.bat diff --git a/public/api-proxy.php b/public/api-proxy.php index 8e465e5..7b87d20 100644 --- a/public/api-proxy.php +++ b/public/api-proxy.php @@ -1,6 +1,14 @@ 'Server misconfiguration: missing API key']); exit; } -$client = new Calco2ApiClient($base, $key); +$client = new Calco2latoApiClient($base, $key); // --- Whitelist router --- $input = json_decode(file_get_contents('php://input') ?: '[]', true) ?: []; @@ -56,11 +64,11 @@ header('Content-Type: application/json; charset=utf-8'); try { switch ($endpoint) { case 'airports.search': - // GET /?endpoint=airports.search&q=FRA&limit=10 + // GET /?endpoint=airports.search&q=FRA&per_page=10 $q = $_GET['q'] ?? ''; - $limit = isset($_GET['limit']) ? (int)$_GET['limit'] : 20; - $offset= isset($_GET['offset']) ? (int)$_GET['offset'] : 0; - $data = $client->searchAirports($q, $limit, $offset); + $per_page = isset($_GET['per_page']) ? (int)$_GET['per_page'] : 20; + $page= isset($_GET['page']) ? (int)$_GET['page'] : 1; + $data = $client->searchAirports($q, $per_page, $page); echo json_encode($data); break; diff --git a/example.html b/public/example.html similarity index 66% rename from example.html rename to public/example.html index 7bacdee..ca01f6d 100644 --- a/example.html +++ b/public/example.html @@ -1,7 +1,13 @@ -