feat: productionize learning engine and classroom
This commit is contained in:
1 parent
2d04197f3f
commit
ba35adfbfa
124 files changed
+9071
-796
No files matched your search
@@ -0,0 +1,26 @@
|
||||
import type { NextRequest } from 'next/server';
|
||||
import { authorizeLearningRuntime, runtimeUnauthorized } from '@/lib/makelore-runtime/auth';
|
||||
import {
|
||||
readFrozenLearningPackageRecord,
|
||||
readUniqueMakeloreCoursePackage,
|
||||
} from '@/lib/makelore-course/package';
|
||||
|
||||
export async function GET(request: NextRequest, context: { params: Promise<{ courseId: string }> }) {
|
||||
if (!authorizeLearningRuntime(request)) return runtimeUnauthorized();
|
||||
const { courseId } = await context.params;
|
||||
const contentHash = request.headers.get('x-content-hash')?.trim() || '';
|
||||
const record = await readFrozenLearningPackageRecord(courseId).catch(() => null);
|
||||
if (!record || record.contentHash !== contentHash) {
|
||||
return Response.json({ error: 'course_not_found' }, { status: 404 });
|
||||
}
|
||||
const bytes = await readUniqueMakeloreCoursePackage(courseId);
|
||||
if (!bytes) return Response.json({ error: 'package_not_found' }, { status: 404 });
|
||||
return new Response(bytes as unknown as BodyInit, {
|
||||
headers: {
|
||||
'Content-Type': 'application/zip',
|
||||
'Content-Length': String(bytes.byteLength),
|
||||
'X-Archive-SHA256': record.archiveSha256,
|
||||
'Cache-Control': 'private, no-store',
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user