commit
This commit is contained in:
25
src/app/api/online-lessons/[id]/attachment/view/route.ts
Normal file
25
src/app/api/online-lessons/[id]/attachment/view/route.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { buildOnlineLessonAttachmentResponse } from '@/features/online-lessons/server/online-lesson-attachment-response';
|
||||
|
||||
type Params = { params: Promise<{ id: string }> };
|
||||
|
||||
export const runtime = 'nodejs';
|
||||
|
||||
function parseLessonId(value: string) {
|
||||
const lessonId = Number(value);
|
||||
return Number.isNaN(lessonId) ? null : lessonId;
|
||||
}
|
||||
|
||||
export async function GET(_request: NextRequest, { params }: Params) {
|
||||
const { id } = await params;
|
||||
const lessonId = parseLessonId(id);
|
||||
|
||||
if (!lessonId) {
|
||||
return NextResponse.json({ message: 'Invalid online lesson attachment request' }, { status: 400 });
|
||||
}
|
||||
|
||||
return buildOnlineLessonAttachmentResponse({
|
||||
lessonId,
|
||||
disposition: 'inline'
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user