From 9c10484f0cb4228a61618ec9ec6bc83ceacbd3a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=C6=B0=E1=BB=A3c=20Nguy=E1=BB=85n=20V=C4=83n?= Date: Mon, 9 Sep 2024 17:37:15 +0700 Subject: [PATCH] refactor(api): rename translate endpoints - Change '/api/translate' to '/api/update-translation' - Change '/api/translate-ai' to '/api/ai-translate' - Update corresponding fetch calls in app.js --- cmd/assets/app.js | 4 ++-- cmd/serve.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/assets/app.js b/cmd/assets/app.js index afb0d5c..0cbe15a 100644 --- a/cmd/assets/app.js +++ b/cmd/assets/app.js @@ -13,7 +13,7 @@ function enableContentEditable() { function updateTranslateContent(translationID, translationContent) { - fetch('/api/translate', { + fetch('/api/update-translation', { method: 'PATCH', headers: { 'Content-Type': 'application/json', @@ -69,7 +69,7 @@ function translateContent(contentId, translationID, button, instructions) { button.textContent = 'Translating...'; button.classList.add('loading'); - fetch('/api/translate-ai', { + fetch('/api/ai-translate', { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/cmd/serve.go b/cmd/serve.go index 53c23bb..d7a01a0 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -296,7 +296,7 @@ func runServe(cmd *cobra.Command, args []string) error { }, }) - app.Patch("/api/translate", func(c *fiber.Ctx) error { + app.Patch("/api/update-translation", func(c *fiber.Ctx) error { var req TranslateRequest if err := c.BodyParser(&req); err != nil { return c.Status(400).JSON(fiber.Map{"error": "Invalid request"}) @@ -375,7 +375,7 @@ func runServe(cmd *cobra.Command, args []string) error { return c.JSON(pkg.Spine) }) - app.Post("/api/translate-ai", func(c *fiber.Ctx) error { + app.Post("/api/ai-translate", func(c *fiber.Ctx) error { var req TranslateAIRequest if err := c.BodyParser(&req); err != nil { return c.Status(400).JSON(fiber.Map{"error": "Invalid request"})