[Breaking] Move automation api into new router with consistent routes

- Rename GET /api/automations to GET /api/automation
- Rename POST /api/trigger/automation to POST /api/automation/trigger
- Update calls to the automations API from the web app.
This commit is contained in:
Debanjum
2025-06-05 00:20:06 -07:00
parent 7dfa710cb4
commit c2cd92a454
4 changed files with 248 additions and 238 deletions

View File

@@ -74,7 +74,7 @@ import { KhojLogoType } from "../components/logo/khojLogo";
const automationsFetcher = () =>
window
.fetch("/api/automations")
.fetch("/api/automation")
.then((res) => res.json())
.catch((err) => console.log(err));
@@ -245,7 +245,7 @@ function deleteAutomation(automationId: string, setIsDeleted: (isDeleted: boolea
}
function sendAPreview(automationId: string, setToastMessage: (toastMessage: string) => void) {
fetch(`/api/trigger/automation?automation_id=${automationId}`, { method: "POST" })
fetch(`/api/automation/trigger?automation_id=${automationId}`, { method: "POST" })
.then((response) => {
if (!response.ok) {
throw new Error("Network response was not ok");