From 430760eca831a3c7abf929fce57d5c107e41ba27 Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Thu, 8 Aug 2024 14:18:27 +0200 Subject: [PATCH] #820 - Update API URLs --- CHANGELOG.md | 4 ++++ src/commands/Backers.ts | 24 ++++++++----------- src/constants/Links.ts | 4 ++-- .../components/Chatbot/Chatbot.tsx | 4 ++-- .../components/Chatbot/Feedback.tsx | 2 +- src/dashboardWebView/index.tsx | 2 +- src/services/SponsorAI.ts | 7 +++--- 7 files changed, 23 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6098947d..34119525 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## [10.2.1] - 2024-08-08 + +- [#820](https://github.com/estruyf/vscode-front-matter/issues/820): Update API links to the new API URL + ## [10.2.0] - 2024-06-12 - [Release notes](https://beta.frontmatter.codes/updates/v10.2.0) ### ✨ New features diff --git a/src/commands/Backers.ts b/src/commands/Backers.ts index 5b743c61..1eaee891 100644 --- a/src/commands/Backers.ts +++ b/src/commands/Backers.ts @@ -22,20 +22,16 @@ export class Backers { const githubAuth = await authentication.getSession('github', ['read:user'], { silent: true }); if (githubAuth && githubAuth.accessToken) { try { - const isBeta = ext.isBetaVersion(); - const response = await fetch( - `https://${isBeta ? `beta.` : ``}frontmatter.codes/api/v2/backers`, - { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - accept: 'application/json' - }, - body: JSON.stringify({ - token: githubAuth.accessToken - }) - } - ); + const response = await fetch(`https://api.frontmatter.codes/v2/backers`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + accept: 'application/json' + }, + body: JSON.stringify({ + token: githubAuth.accessToken + }) + }); if (response.ok) { const prevData = await ext.getState(CONTEXT.backer, 'global'); diff --git a/src/constants/Links.ts b/src/constants/Links.ts index 7c839c31..e27e94a5 100644 --- a/src/constants/Links.ts +++ b/src/constants/Links.ts @@ -14,8 +14,8 @@ export const DOCS_SUBMODULES = 'https://frontmatter.codes/docs/git-integration#g export const WEBSITE_LINKS = { root: 'https://frontmatter.codes', api: { - metrics: 'https://frontmatter.codes/api/metrics', - ai: 'https://frontmatter.codes/api/ai' + root: 'https://api.frontmatter.codes', + metrics: 'https://api.frontmatter.codes/metrics' }, docs: { dataDashboard: 'https://frontmatter.codes/docs/dashboard/datafiles-view', diff --git a/src/dashboardWebView/components/Chatbot/Chatbot.tsx b/src/dashboardWebView/components/Chatbot/Chatbot.tsx index 295cb9fa..c2dba4ab 100644 --- a/src/dashboardWebView/components/Chatbot/Chatbot.tsx +++ b/src/dashboardWebView/components/Chatbot/Chatbot.tsx @@ -36,7 +36,7 @@ export const Chatbot: React.FunctionComponent = ({ }: React.Props setLocaleReady(true); }); - const initResponse = await fetch(`${aiUrl}/api/ai-init`); + const initResponse = await fetch(`${aiUrl}/ai-init`); if (!initResponse.ok) { return; @@ -70,7 +70,7 @@ export const Chatbot: React.FunctionComponent = ({ }: React.Props return; } - const response = await fetch(`${aiUrl}/api/ai-chat`, { + const response = await fetch(`${aiUrl}/ai-chat`, { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/src/dashboardWebView/components/Chatbot/Feedback.tsx b/src/dashboardWebView/components/Chatbot/Feedback.tsx index 535d3ee7..b878cc35 100644 --- a/src/dashboardWebView/components/Chatbot/Feedback.tsx +++ b/src/dashboardWebView/components/Chatbot/Feedback.tsx @@ -28,7 +28,7 @@ export const Feedback: React.FunctionComponent = ({ }, []); const callVote = useCallback(async (vote: boolean) => { - await fetch(`${aiUrl}/api/ai-feedback`, { + await fetch(`${aiUrl}/ai-feedback`, { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/src/dashboardWebView/index.tsx b/src/dashboardWebView/index.tsx index 24a93426..2c0fbdc7 100644 --- a/src/dashboardWebView/index.tsx +++ b/src/dashboardWebView/index.tsx @@ -93,7 +93,7 @@ if (elm) { render( diff --git a/src/services/SponsorAI.ts b/src/services/SponsorAI.ts index 1bf7a9b2..10e86214 100644 --- a/src/services/SponsorAI.ts +++ b/src/services/SponsorAI.ts @@ -9,7 +9,6 @@ import { TaxonomyType } from '../models'; import * as l10n from '@vscode/l10n'; import { LocalizationKey } from '../localization'; -const AI_URL = WEBSITE_LINKS.api.ai; // const AI_URL = 'http://localhost:3000/api/ai'; export class SponsorAi { @@ -28,7 +27,7 @@ export class SponsorAi { }, 10000); const signal = controller.signal; - const response = await fetch(`${AI_URL}/title`, { + const response = await fetch(`${WEBSITE_LINKS.api.root}/ai/title`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -66,7 +65,7 @@ export class SponsorAi { articleContent = articleContent.substring(0, 2000); } - const response = await fetch(`${AI_URL}/description`, { + const response = await fetch(`${WEBSITE_LINKS.api.root}/ai/description`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -129,7 +128,7 @@ export class SponsorAi { taxonomy: optionsString }); - const response = await fetch(`${AI_URL}/taxonomy`, { + const response = await fetch(`${WEBSITE_LINKS.api.root}/ai/taxonomy`, { method: 'POST', headers: { 'Content-Type': 'application/json',