RYP / src /lib /systemDesignClient.ts
Soumya79's picture
Upload 1361 files
f91a684 verified
export interface SystemDesignTopic {
id: string;
chapter_no: number;
chapter_name: string;
subtitle: string;
level: string;
}
export interface SystemDesignTopicContent extends SystemDesignTopic {
content: any; // Raw JSON object from MongoDB
}
export async function fetchSystemDesignTopics(): Promise<SystemDesignTopic[]> {
const res = await fetch('/api/system-design/topics');
if (!res.ok) throw new Error('Failed to fetch topics');
const data = await res.json();
return data.topics || [];
}
export async function fetchSystemDesignTopicContent(chapterNo: number): Promise<SystemDesignTopicContent> {
const res = await fetch(`/api/system-design/topics/${chapterNo}`);
if (!res.ok) throw new Error('Failed to fetch topic content');
return res.json();
}