Skip to main content

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

PitchPro’s backend is an Express + TypeScript REST API that exposes all court and reservation management functionality over HTTP. Every response is JSON. Protected routes (/api/canchas and /api/reservas) require a valid JWT Bearer token issued at login. An interactive Swagger UI is bundled at /docs so you can explore and test every endpoint directly from the browser.

Base URL

http://localhost:8000   # local development
The server port defaults to 8000 but can be overridden with the PORT environment variable. All application routes are grouped under the following prefixes:
PrefixDescription
/api/auth/*Authentication routes (register, login, refresh, logout, me)
/api/canchasCourt management (list, get, create)
/api/reservasReservation management (list, create)
/healthService health check

Authentication

Endpoints under /api/canchas and /api/reservas are protected by the verifyToken middleware. Every request to these routes must include a valid JWT access token in the Authorization header:
Authorization: Bearer <accessToken>
Omitting the header, or sending an expired or malformed token, returns a 401 Unauthorized response:
{
  "message": "Acceso denegado. Token no proporcionado."
}
See Authentication for the full step-by-step guide on registering, logging in, and refreshing tokens.

Response Format

All API responses are JSON. The main resource endpoints (/api/canchas, /api/reservas) wrap their payloads in a consistent envelope:
{
  "ok": true,
  "total": 5,
  "data": [...]
}
Error responses follow a unified error shape:
{
  "ok": false,
  "mensaje": "Error message"
}
Validation errors from express-validator (auth routes) return an errors array instead:
{
  "errors": [
    { "msg": "Debe ser un email válido" }
  ]
}
Auth responses from /api/auth/login return a flat object rather than the envelope — the shape includes the token pair and the authenticated user:
{
  "accessToken": "eyJhbGciOiJIUzI1NiIs...",
  "refreshToken": "eyJhbGciOiJIUzI1NiIs...",
  "user": {
    "id": 1,
    "nombre": "Juan Pérez",
    "email": "juan@example.com"
  }
}

HTTP Status Codes

CodeStatusWhen it occurs
200OKSuccessful GET request
201CreatedSuccessful POST that creates a resource
400Bad RequestValidation error (missing fields, invalid email, duplicate email on register, invalid credentials on login)
401UnauthorizedMissing or invalid/expired Bearer token
403ForbiddenInvalid or expired refresh token supplied to /api/auth/refresh
404Not FoundRequested resource (court, user) does not exist
409ConflictReservation time-slot overlap — the court is already booked for the requested period
422Unprocessable EntityZod schema validation failure on POST /api/canchas
500Internal Server ErrorUnexpected server-side error

Endpoints Index

The API exposes 11 endpoints across four route groups:
MethodPathAuth RequiredDescription
POST/api/auth/registerNoCreate a new user account
POST/api/auth/loginNoLog in and receive accessToken + refreshToken
POST/api/auth/refreshNoExchange a refresh token for a new access token
POST/api/auth/logoutNoNullify the stored refresh token and end the session
GET/api/auth/meBearerRetrieve the currently authenticated user’s profile
GET/api/canchasBearerList all registered courts
GET/api/canchas/:idBearerGet a single court by its ID
POST/api/canchasBearerCreate a new court
GET/api/reservasBearerList all reservations (with court name joined)
POST/api/reservasBearerCreate / schedule a new reservation
GET/healthNoService and database health check

Swagger UI

The backend ships with a bundled Swagger UI (OpenAPI 3.0) automatically mounted at /docs. Use it to browse all endpoints, inspect request/response schemas, and send test requests without any extra tooling:
http://localhost:8000/docs
The Swagger document is defined in src/swagger.ts and covers all cancha and reserva endpoints as well as the health check. Auth routes carry express-validator middleware but are not currently included in the OpenAPI spec — use the curl examples in Authentication for those.

Authentication

Step-by-step guide to registering, logging in, refreshing tokens, and logging out.

Auth Endpoints

Detailed reference for all five /api/auth/* routes.

Courts (Canchas)

List, retrieve, and create sports courts.

Reservations (Reservas)

Schedule and list court reservations.

Build docs developers (and LLMs) love