eoSalinas / eoSalinas/verse

Create `get-random-verse` endpoint

Open
#55 2 comments 0 reactions 1 assignee Claimed by @Dnreikronos View on GitHub
enhancement good first issue
Dominant language
TypeScript
Stars
41
Forks
9
PR merge metrics
No merged PRs in 30d

Description

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.:

```json
{
"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)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.