File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed
Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import connectDB from "@/database/db";
22import Event from "@/database/eventSchema" ;
33import { NextRequest , NextResponse } from "next/server" ;
44import mongoose from "mongoose" ;
5+ import Session from "@/database/sessionSchema" ;
56
67export async function GET ( request : NextRequest ) {
78 try {
@@ -23,6 +24,11 @@ export async function GET(request: NextRequest) {
2324 filter . sessionId = new mongoose . Types . ObjectId ( sessionId ) ;
2425 }
2526
27+ const sessionExists = await Session . exists ( { _id : sessionId } ) ;
28+ if ( ! sessionExists ) {
29+ return NextResponse . json ( { error : "Session not found" } , { status : 404 } ) ;
30+ }
31+
2632 const events = await Event . find ( filter ) . sort ( { ts : - 1 } ) ;
2733
2834 return NextResponse . json ( events ) ;
You can’t perform that action at this time.
0 commit comments