Skip to content

Commit

Permalink
#820 - Update API URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
estruyf committed Aug 8, 2024
1 parent 5353d07 commit 430760e
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 24 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
24 changes: 10 additions & 14 deletions src/commands/Backers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean>(CONTEXT.backer, 'global');
Expand Down
4 changes: 2 additions & 2 deletions src/constants/Links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions src/dashboardWebView/components/Chatbot/Chatbot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const Chatbot: React.FunctionComponent<IChatbotProps> = ({ }: React.Props
setLocaleReady(true);
});

const initResponse = await fetch(`${aiUrl}/api/ai-init`);
const initResponse = await fetch(`${aiUrl}/ai-init`);

if (!initResponse.ok) {
return;
Expand Down Expand Up @@ -70,7 +70,7 @@ export const Chatbot: React.FunctionComponent<IChatbotProps> = ({ }: 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',
Expand Down
2 changes: 1 addition & 1 deletion src/dashboardWebView/components/Chatbot/Feedback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const Feedback: React.FunctionComponent<IFeedbackProps> = ({
}, []);

const callVote = useCallback(async (vote: boolean) => {
await fetch(`${aiUrl}/api/ai-feedback`, {
await fetch(`${aiUrl}/ai-feedback`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down
2 changes: 1 addition & 1 deletion src/dashboardWebView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ if (elm) {
render(
<I10nProvider>
<SettingsProvider
aiUrl={WEBSITE_LINKS.root}
aiUrl={WEBSITE_LINKS.api.root}
experimental={experimental === 'true'}
version={version || ""}>
<Chatbot />
Expand Down
7 changes: 3 additions & 4 deletions src/services/SponsorAI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 430760e

Please sign in to comment.