Skip to content

Feat/get event by - #317

Open
egwujiohaifesinachiperpetual-max wants to merge 10 commits into
Open-audit-foundation:mainfrom
egwujiohaifesinachiperpetual-max:feat/get-event-by-id
Open

Feat/get event by#317
egwujiohaifesinachiperpetual-max wants to merge 10 commits into
Open-audit-foundation:mainfrom
egwujiohaifesinachiperpetual-max:feat/get-event-by-id

Conversation

@egwujiohaifesinachiperpetual-max

Copy link
Copy Markdown
Contributor

Closes #295

Summary

This PR adds a new endpoint to retrieve a single event by its unique ID. It satisfies the need for dashboard deep-linking and external API consumer event lookups.

What's Changed

  • Created GET /api/v1/events/[id]/route.ts implementing:
    • API Token authentication and rate limiting checks.
    • Asynchronous dynamic parameter parsing compatible with Next.js 15+.
    • Querying the Prisma Event table on the id field.
    • Returning the event as JSON or a 404 response if the event is not found.
    • Response schema documented inside the file comments.
  • Added comprehensive unit tests in app/api/v1/events/[id]/route.test.ts covering:
    • 401 Unauthorized handling when authentication fails.
    • 404 Not Found handling when the event does not exist.
    • 200 OK returns the correct event.
    • 500 Internal Server Error when DB queries fail.

Verification

Unit tests pass successfully:

npx vitest run "app/api/v1/events/[id]/route.test.ts"

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.

Add a GET /api/v1/events/:id endpoint for fetching a single event by ID

2 participants