Protected endpoints (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.
/api/canchas and /api/reservas) require a JWT access token. Obtain one by registering an account and logging in, then include it in the Authorization header of every subsequent request. Access tokens are short-lived (15 minutes); use the refresh token to get a new one without re-entering credentials.
Register an account
Create a new user account by posting Successful response — The response intentionally omits the hashed password. Store the
nombre, email, and password to /api/auth/register. Passwords must be at least 6 characters long and emails must be unique across the system.201 Created:id if you need it, but logging in (next step) will return the full user object again.Log in
Exchange your credentials for an access token and a refresh token by posting to Successful response — Save both tokens securely. You will need the
/api/auth/login.200 OK:The refresh token is persisted in the
users table (refresh_token column). Only one refresh token is active per user at a time — logging in again overwrites the previous one.accessToken for every protected request and the refreshToken to obtain a new access token once it expires.Make authenticated requests
Attach the access token to every request that targets a protected route by setting the The or, for an invalid/expired token:You can also retrieve the currently authenticated user’s profile with the
Authorization header to Bearer <accessToken>:verifyToken middleware validates the token on every request to /api/canchas/* and /api/reservas/*. If the token is missing, malformed, or expired you will receive:/api/auth/me endpoint:Refreshing the Token
Access tokens expire in 15 minutes. When a request returns401, use the refresh token to obtain a new access token without requiring the user to log in again.
Post the stored refresh token to /api/auth/refresh:
200 OK:
Logout
Send the refresh token to/api/auth/logout to invalidate the session. The server sets refresh_token = NULL in the database for the matching user, preventing the token from ever being used again.
200 OK:
accessToken and refreshToken from client-side storage. Any subsequent requests using the old access token will continue to succeed until the 15-minute expiry window closes, but the refresh token will no longer be exchangeable.
Token Expiry Reference
| Token | Lifetime | Notes |
|---|---|---|
accessToken | 15 minutes | Short-lived; signed with JWT_SECRET; carries id and email claims |
refreshToken | 7 days | Long-lived; signed with JWT_REFRESH_SECRET; carries id claim only; stored in DB |
Frontend usage — The React dashboard stores the access token in
sessionStorage under the key 'accessToken' and automatically injects it into every outbound API call via an Axios request interceptor. The interceptor reads sessionStorage.getItem('accessToken') and appends the Authorization: Bearer <token> header before the request is sent, so you never need to set the header manually in frontend code.Auth Endpoints
Full reference for all five
/api/auth/* routes — schemas, validation rules, and error codes.Backend Authentication
How
verifyToken middleware, bcrypt hashing, and JWT signing work under the hood.Frontend Auth Flow
How the React dashboard handles login state,
sessionStorage, and the Axios interceptor.API Overview
Base URL, response envelope format, status codes, and the full endpoint index.