Skip to content

Create get-random-verse endpoint #55

@eoSalinas

Description

@eoSalinas

We need to create a new API endpoint that returns a random verse from the database. This will allow users to fetch a different verse each time they hit the endpoint.

Requirements

  • Create a new route: GET /api/verses/random
  • Query the database to fetch a random verse (Prisma ORM)
  • Return the verse in a structured JSON response, e.g.:
{
  "id": "39fbbe93-8678-474e-b1ad-2dee322ae676",
  "book": "Salmos",
  "chapter": "23",
  "verse": "1",
  "content": "O Senhor é o meu pastor, nada me faltará",
  "author": "Davi"
}
  • Ensure the endpoint handles cases where no verses exist in the database

Tasks

  • Implement the GET /api/verses/random route
  • Add the database query to fetch a random verse
  • Structure the response correctly
  • Handle potential errors (e.g., empty database)

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions