feat: add project and email service

This commit is contained in:
Jet Pham 2026-03-11 13:00:51 -07:00 committed by Jet
parent 99715f6105
commit f48390b15e
29 changed files with 2631 additions and 63 deletions

25
src/lib/api.ts Normal file
View file

@ -0,0 +1,25 @@
export interface Question {
id: number;
question: string;
answer: string;
created_at: string;
answered_at: string;
}
export async function getQuestions(): Promise<Question[]> {
const res = await fetch("/api/questions");
if (!res.ok) throw new Error("Failed to fetch questions");
return res.json() as Promise<Question[]>;
}
export async function submitQuestion(question: string): Promise<void> {
const res = await fetch("/api/questions", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ question }),
});
if (!res.ok) {
if (res.status === 429) throw new Error("Too many questions. Please try again later.");
throw new Error("Failed to submit question");
}
}