Merged
Conversation
kaseyliu
requested changes
Feb 27, 2026
|
|
||
| if (!mongoose.Types.ObjectId.isValid(sessionId)) { | ||
| return NextResponse.json({ error: "Invalid sessionId" }, { status: 400 }); | ||
| } |
Collaborator
There was a problem hiding this comment.
Nice check for if the sessionid is valid! Can you also add a check for if the session exists? Something like this:
const sessionExists = await Session.exists({ _id: sessionId });
if (!sessionExists) {
return NextResponse.json({ error: "Session not found" }, { status: 404 });
}
Collaborator
|
Tested in Postman, and both work as expected! Great job! |
kaseyliu
approved these changes
Mar 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Developer: Trisha Chandwani
Closes #K1-19
Pull Request Summary
Adds MongoDB event tracking by creating the "eventsSchema.ts" model and the GET and POST API endpoints for events. Created a schema for an event which stores event data including a reference to the associated session, an anonymous user ID, a timestamp, and an optional props object for game-specific data like gameid, durationms, and result.
Modifications
Created a file called route.ts in a new folder called events (src -> api -> app -> events -> route.ts) . Creates a model and the GET and POST API endpoints for events.
Created a file called eventsSchema.ts (src -> app -> dashboard -> eventsSchema.ts). Creates the schema for events storig the data for the variables given in the issue.
Testing Considerations
I haven't really tested it, but I did it based off the other files in the folders, so I think it will.
Pull Request Checklist