Skip to content

K1-19 Endpoints and Schema for Events#13

Merged
kaseyliu merged 2 commits intodevelopfrom
K1-19-Events-Endpoints-and-Schema
Mar 3, 2026
Merged

K1-19 Endpoints and Schema for Events#13
kaseyliu merged 2 commits intodevelopfrom
K1-19-Events-Endpoints-and-Schema

Conversation

@tchandwani
Copy link
Copy Markdown
Collaborator

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

  • Code is neat, readable, and works
  • Comments are appropriate
  • The commit messages follows our guidelines
  • The developer name is specified
  • The summary is completed
  • Assign reviewers


if (!mongoose.Types.ObjectId.isValid(sessionId)) {
return NextResponse.json({ error: "Invalid sessionId" }, { status: 400 });
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 });
}

@kaseyliu
Copy link
Copy Markdown
Collaborator

Tested in Postman, and both work as expected! Great job!

@kaseyliu kaseyliu merged commit 679fb21 into develop Mar 3, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants