import { db } from "../../../db/index"; import { topics, lessons } from "../../../db/schema"; import { eq } from "drizzle-orm"; 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" }); const lesson = await db.query.lessons.findFirst({ where: eq(lessons.topicId, id) }); if (!lesson) throw createError({ statusCode: 404, message: "No lesson for this topic" }); return { branchStatus: lesson.branchStatus }; });