adding search
Deploy / deploy (push) Successful in 8s

This commit is contained in:
2026-05-06 12:33:20 +02:00
parent 556ac06413
commit 36abf1bdd4
5 changed files with 134 additions and 9 deletions
+13
View File
@@ -73,6 +73,8 @@ class Router
preg_match('#^/alerts/counts$#', $path) && $method === 'GET'
=> $this->repo->getAlertCounts(),
$path === '/logs/search' && $method === 'GET' => $this->searchLogs(),
$path === '/config/allowed_tokens' && $method === 'GET'
=> ['tokens' => $this->repo->getAllowedUserTokens()],
$path === '/config/allowed_tokens' && $method === 'PUT'
@@ -204,6 +206,17 @@ class Router
return $this->repo->searchAlerts($query, $limit);
}
private function searchLogs(): array
{
$query = $_GET['q'] ?? '';
if (empty($query)) {
return ['data' => []];
}
$limit = (int) ($_GET['limit'] ?? 200);
$offset = (int) ($_GET['offset'] ?? 0);
return ['data' => $this->repo->searchLogEntries($query, $limit, $offset)];
}
private function updateAllowedTokens(): array
{
$body = json_decode(file_get_contents('php://input'), true);