(userId: string, courseId: string)
| 2 | import { NextResponse, NextRequest } from 'next/server'; |
| 3 | |
| 4 | async function checkUserCourseAccess(userId: string, courseId: string) { |
| 5 | const userCourse = await db.course.findFirst({ |
| 6 | where: { |
| 7 | purchasedBy: { |
| 8 | some: { |
| 9 | userId, |
| 10 | }, |
| 11 | }, |
| 12 | id: parseInt(courseId, 10), |
| 13 | }, |
| 14 | }); |
| 15 | |
| 16 | return userCourse !== null; |
| 17 | } |
| 18 | |
| 19 | export async function GET( |
| 20 | request: NextRequest, |