This commit is contained in:
Team3
2026-06-06 00:14:43 +02:00
parent 3ed5f7c3e5
commit a8fbf83059
39 changed files with 7347 additions and 472 deletions

View File

@@ -1,6 +1,64 @@
const BASE = '/api'
export async function fetchHealth() {
const res = await fetch(`${BASE}/health`)
export async function fetchGuides() {
const res = await fetch(`${BASE}/guides`)
return res.json()
}
export async function createGuide(topic, format, instructions = '', provider = 'claude') {
const res = await fetch(`${BASE}/guides`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ topic, format, instructions, provider }),
})
return res.json()
}
export async function fetchProviders() {
const res = await fetch(`${BASE}/providers`)
return res.json()
}
export async function fetchProjects() {
const res = await fetch(`${BASE}/projects`)
return res.json()
}
export async function deleteProject(name) {
await fetch(`${BASE}/projects/${encodeURIComponent(name)}`, { method: 'DELETE' })
}
export async function cancelGuide(id) {
await fetch(`${BASE}/guides/${id}/cancel`, { method: 'POST' })
}
export async function deleteGuide(id) {
await fetch(`${BASE}/guides/${id}`, { method: 'DELETE' })
}
export function htmlUrl(id) {
return `${BASE}/guides/${id}/html`
}
export async function fetchProgress(id) {
const res = await fetch(`${BASE}/guides/${id}/progress`)
return res.json()
}
export async function setProgress(id, chapter, done) {
const res = await fetch(`${BASE}/guides/${id}/progress`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ chapter, done }),
})
return res.json()
}
export async function chatGuide(id, { section, outline, messages, provider = 'claude' }) {
const res = await fetch(`${BASE}/guides/${id}/chat`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ section, outline, messages, provider }),
})
return res.json()
}