Skip to content

Commit

Permalink
refactor(api): rename translate endpoints
Browse files Browse the repository at this point in the history
- Change '/api/translate' to '/api/update-translation'
- Change '/api/translate-ai' to '/api/ai-translate'
- Update corresponding fetch calls in app.js
  • Loading branch information
duocnv-firegroup committed Sep 9, 2024
1 parent 8241aad commit 9c10484
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cmd/assets/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function enableContentEditable() {


function updateTranslateContent(translationID, translationContent) {
fetch('/api/translate', {
fetch('/api/update-translation', {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"})
Expand Down Expand Up @@ -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"})
Expand Down

0 comments on commit 9c10484

Please sign in to comment.