initialize project with basic structure and dependencies

This commit is contained in:
ImBenji
2026-04-27 23:59:15 +01:00
parent 83f2837ce6
commit f6f45500f8
13 changed files with 1443 additions and 579 deletions
+27
View File
@@ -0,0 +1,27 @@
import { db } from "../../../db/index";
import { topics, lessons } from "../../../db/schema";
import { eq } from "drizzle-orm";
import { generateLesson } from "../../../utils/generateLesson";
export default defineEventHandler(async (event) => {
const id = getRouterParam(event, "id")!;
const topic = await db.query.topics.findFirst({ where: eq(topics.id, id) });
if (!topic) throw createError({ statusCode: 404, message: "Topic not found" });
if (topic.status === "ready") {
return { status: "ready" };
}
if (topic.status === "generating") {
return { status: "generating" };
}
try {
await generateLesson(id);
return { status: "ready" };
} catch (err: any) {
console.error(`[generate.post] topic ${id} failed: ${err?.message ?? err}`);
return { status: "error" };
}
});
+1
View File
@@ -14,5 +14,6 @@ export default defineEventHandler(async (event) => {
return {
...lesson,
content: JSON.parse(lesson.content),
branchStatus: lesson.branchStatus,
};
});