adding new mindforge applications
All checks were successful
Mindforge API Build and Deploy / Build Mindforge API Image (push) Successful in 1m8s
Mindforge Cronjob Build and Deploy / Build Mindforge Cronjob Image (push) Successful in 1m19s
Mindforge API Build and Deploy / Deploy Mindforge API (internal) (push) Successful in 11s
Mindforge Cronjob Build and Deploy / Deploy Mindforge Cronjob (internal) (push) Successful in 10s
Mindforge Web Build and Deploy (internal) / Build Mindforge Web Image (push) Successful in 2m25s
Mindforge Web Build and Deploy (internal) / Deploy Mindforge Web (internal) (push) Successful in 12s
All checks were successful
Mindforge API Build and Deploy / Build Mindforge API Image (push) Successful in 1m8s
Mindforge Cronjob Build and Deploy / Build Mindforge Cronjob Image (push) Successful in 1m19s
Mindforge API Build and Deploy / Deploy Mindforge API (internal) (push) Successful in 11s
Mindforge Cronjob Build and Deploy / Deploy Mindforge Cronjob (internal) (push) Successful in 10s
Mindforge Web Build and Deploy (internal) / Build Mindforge Web Image (push) Successful in 2m25s
Mindforge Web Build and Deploy (internal) / Deploy Mindforge Web (internal) (push) Successful in 12s
This commit is contained in:
56
Mindforge.Web/src/services/MindforgeApiService.ts
Normal file
56
Mindforge.Web/src/services/MindforgeApiService.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
const BASE_URL = import.meta.env.VITE_API_BASE_URL || 'http://localhost:5123';
|
||||
|
||||
export interface CheckFileRequest {
|
||||
fileContent: string;
|
||||
fileName: string;
|
||||
checkType: 'language' | 'content';
|
||||
}
|
||||
|
||||
export interface CheckFileResponse {
|
||||
result: string;
|
||||
}
|
||||
|
||||
export interface GenerateFlashcardsRequest {
|
||||
fileContent: string;
|
||||
fileName: string;
|
||||
amount: number;
|
||||
mode: FlashcardMode;
|
||||
}
|
||||
|
||||
export type FlashcardMode = 'Basic' | 'Simple' | 'Detailed' | 'Hyper';
|
||||
|
||||
export interface GenerateFlashcardsResponse {
|
||||
result: string;
|
||||
}
|
||||
|
||||
export const MindforgeApiService = {
|
||||
async checkFile(data: CheckFileRequest): Promise<CheckFileResponse> {
|
||||
const response = await fetch(`${BASE_URL}/api/v1/file/check`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Error checking file: ${response.statusText}`);
|
||||
}
|
||||
return response.json();
|
||||
},
|
||||
|
||||
async generateFlashcards(data: GenerateFlashcardsRequest): Promise<GenerateFlashcardsResponse> {
|
||||
const response = await fetch(`${BASE_URL}/api/v1/flashcard/generate`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Error generating flashcards: ${response.statusText}`);
|
||||
}
|
||||
return response.json();
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user