feat: productionize learning engine and classroom
This commit is contained in:
25
OpenMAIC/app/api/runtime/v1/bindings/validate/route.ts
Normal file
25
OpenMAIC/app/api/runtime/v1/bindings/validate/route.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import type { NextRequest } from 'next/server';
|
||||
import { authorizeLearningRuntime, runtimeUnauthorized } from '@/lib/makelore-runtime/auth';
|
||||
import { loadMakeloreCourse, parseLearningBinding } from '@/lib/makelore-runtime/course-store';
|
||||
import { isRuntimeOpenRequest } from '@/lib/makelore-runtime/protocol';
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
if (!authorizeLearningRuntime(request)) return runtimeUnauthorized();
|
||||
const body: unknown = await request.json().catch(() => null);
|
||||
if (!isRuntimeOpenRequest(body)) return Response.json({ error: 'invalid_request' }, { status: 400 });
|
||||
const binding = parseLearningBinding(body.binding.key);
|
||||
if (!binding) return Response.json({ error: 'invalid_binding' }, { status: 400 });
|
||||
const course = await loadMakeloreCourse(binding.courseId, binding.contentHash);
|
||||
if (!course) return Response.json({ error: 'course_not_found' }, { status: 404 });
|
||||
return Response.json({
|
||||
type: 'learning.course.snapshot',
|
||||
schema_version: 1,
|
||||
binding_source_sequence: 0,
|
||||
payload: {
|
||||
courseId: course.courseId,
|
||||
contentHash: course.contentHash,
|
||||
title: course.title,
|
||||
sceneCount: course.sceneCount,
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user