TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/JuanSerna14/Final-lenguaje-Avanzado/llms.txt
Use this file to discover all available pages before exploring further.
/api/canchas endpoints manage sports courts (canchas) — the bookable venues in PitchPro. All three routes are mounted behind the verifyToken middleware in main.ts, meaning every request must supply a valid JWT Bearer token in the Authorization header.
GET /api/canchas
Returns an ordered list of every court in the database (ORDER BY id ASC).
Authentication
All/api/canchas requests require Authorization: Bearer <accessToken>.
Example request
Response — 200 OK
Always
true on a successful response.Count of courts returned in
data. Equals data.length.Error codes
| Code | Meaning |
|---|---|
401 | Missing or invalid Bearer token |
500 | Internal server error |
GET /api/canchas/:id
Fetches a single court by its integer primary key.Authentication
RequiresAuthorization: Bearer <accessToken>.
Path parameters
The numeric ID of the court. Must be a positive integer. Non-numeric or zero values return
400.Example request
Response — 200 OK
Always
true on a successful response.Error codes
| Code | Meaning |
|---|---|
400 | id path segment is not a positive integer — { ok: false, mensaje: "El ID debe ser un número positivo" } |
401 | Missing or invalid Bearer token |
404 | No court found with that ID — { ok: false, mensaje: "Cancha con ID <id> no encontrada" } (thrown as CanchaNoEncontradaError) |
500 | Internal server error |
POST /api/canchas
Creates a new court record. The request body is validated with the Zod schemaCrearCanchaSchema defined in canchas.types.ts. Any Zod validation failure returns 422 with a structured error array.
Authentication
RequiresAuthorization: Bearer <accessToken>.
Request body
The court’s display name. Must be at least 1 character and no more than 100 characters.
Optional free-text description (e.g. surface type, lighting, capacity). Omit or pass
null to leave blank.Hourly rental rate in the local currency. Must be a positive number greater than 0. Send as a JS
number in the JSON body (e.g. 80000). The database stores it as DECIMAL and the API returns it as a string.Whether the court should be immediately available for booking. Defaults to
true if omitted.Example request
Response — 201 Created
Always
true on successful creation.The newly created court object returned from
RETURNING *, including the auto-assigned id and created_at timestamp.precio_hora is sent as a JS number in the request body (e.g. 80000) but is always returned as a string (e.g. "80000.00") in responses, because the PostgreSQL DECIMAL type is serialised as a string by the pg driver to preserve precision.Response — 422 Unprocessable Entity
Returned when the body failsCrearCanchaSchema Zod parsing.
Always
false on a validation failure.Always
"Datos de entrada inválidos" for Zod errors.Error codes
| Code | Meaning |
|---|---|
401 | Missing or invalid Bearer token |
422 | Request body failed Zod schema validation |
500 | Internal server error |
Reservations API
Book a court for a specific date and time slot. Includes overlap conflict detection.
API Overview
All PitchPro endpoints at a glance with base URL, auth format, and error conventions.
Authentication Guide
Learn how to obtain and refresh Bearer tokens to authenticate all court requests.