mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-08-11 03:12:44 +02:00
#820 - Update endpoints
This commit is contained in:
+13
-11
@@ -22,17 +22,19 @@ 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(`${WEBSITE_LINKS.api.url}/api/v2/backers`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
accept: 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
token: githubAuth.accessToken
|
||||
})
|
||||
});
|
||||
const response = await fetch(
|
||||
`${WEBSITE_LINKS.api.baseUrl}${WEBSITE_LINKS.api.endpoints.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');
|
||||
|
||||
+10
-3
@@ -14,9 +14,16 @@ export const DOCS_SUBMODULES = 'https://frontmatter.codes/docs/git-integration#g
|
||||
export const WEBSITE_LINKS = {
|
||||
root: 'https://frontmatter.codes',
|
||||
api: {
|
||||
url: 'https://fontmatter-fncs.azurewebsites.net',
|
||||
metrics: 'https://frontmatter.codes/api/metrics',
|
||||
ai: 'https://frontmatter.codes/api/ai'
|
||||
baseUrl: 'https://fontmatter-fncs.azurewebsites.net',
|
||||
endpoints: {
|
||||
ai: '/api/ai',
|
||||
chat: {
|
||||
init: '/api/ai-init',
|
||||
message: '/api/ai-chat',
|
||||
feedback: '/api/ai-feedback'
|
||||
},
|
||||
backers: '/api/backers'
|
||||
}
|
||||
},
|
||||
docs: {
|
||||
dataDashboard: 'https://frontmatter.codes/docs/dashboard/datafiles-view',
|
||||
|
||||
@@ -10,7 +10,7 @@ import { AiInitResponse } from './models/AiInitResponse';
|
||||
import * as l10n from '@vscode/l10n';
|
||||
import { LocalizationKey } from '../../../localization';
|
||||
import { messageHandler } from '@estruyf/vscode/dist/client';
|
||||
import { GeneralCommands } from '../../../constants';
|
||||
import { GeneralCommands, WEBSITE_LINKS } from '../../../constants';
|
||||
|
||||
export interface IChatbotProps { }
|
||||
|
||||
@@ -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}${WEBSITE_LINKS.api.endpoints.chat.init}`);
|
||||
|
||||
if (!initResponse.ok) {
|
||||
return;
|
||||
@@ -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}${WEBSITE_LINKS.api.endpoints.chat.message}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
||||
@@ -3,6 +3,7 @@ import { HandThumbDownIcon, HandThumbUpIcon } from '@heroicons/react/24/outline'
|
||||
import { HandThumbDownIcon as ThumbDownSolidIcon, HandThumbUpIcon as ThumbUpSolidIcon } from '@heroicons/react/24/solid';
|
||||
import { useCallback } from 'react';
|
||||
import { useSettingsContext } from '../../providers/SettingsProvider';
|
||||
import { WEBSITE_LINKS } from '../../../constants';
|
||||
|
||||
export interface IFeedbackProps {
|
||||
answerId: number;
|
||||
@@ -28,7 +29,7 @@ export const Feedback: React.FunctionComponent<IFeedbackProps> = ({
|
||||
}, []);
|
||||
|
||||
const callVote = useCallback(async (vote: boolean) => {
|
||||
await fetch(`${aiUrl}/api/ai-feedback`, {
|
||||
await fetch(`${aiUrl}${WEBSITE_LINKS.api.endpoints.chat.feedback}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
||||
@@ -93,7 +93,7 @@ if (elm) {
|
||||
render(
|
||||
<I10nProvider>
|
||||
<SettingsProvider
|
||||
aiUrl={WEBSITE_LINKS.api.url}
|
||||
aiUrl={WEBSITE_LINKS.api.baseUrl}
|
||||
experimental={experimental === 'true'}
|
||||
version={version || ""}>
|
||||
<Chatbot />
|
||||
|
||||
@@ -9,7 +9,7 @@ import { TaxonomyType } from '../models';
|
||||
import * as l10n from '@vscode/l10n';
|
||||
import { LocalizationKey } from '../localization';
|
||||
|
||||
const AI_URL = `${WEBSITE_LINKS.api.url}/api/ai`;
|
||||
const AI_URL = `${WEBSITE_LINKS.api.baseUrl}${WEBSITE_LINKS.api.endpoints.ai}`;
|
||||
// const AI_URL = 'http://localhost:3000/api/ai';
|
||||
|
||||
export class SponsorAi {
|
||||
|
||||
Reference in New Issue
Block a user