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/auth prefix groups all authentication endpoints. Requests to these routes do not require a JWT token — with the single exception of GET /api/auth/me, which validates the caller’s access token to return their profile.
POST /api/auth/register
Creates a new user account. The request body is validated byexpress-validator before the handler runs; if any field fails, a 400 is returned before any database query is made.
Request body
Display name for the user. Must be non-empty (validated by
express-validator notEmpty()).Must be a valid email address (validated by
express-validator isEmail()). If the address is already registered, a 400 is returned.Plain-text password. Must be at least 6 characters (
isLength({ min: 6 })). Stored as a bcrypt hash (salt rounds: 10).Example request
Response — 201 Created
Error codes
| Code | Meaning |
|---|---|
400 | Email already registered — { errors: [{ msg: "El email ya está registrado" }] } |
400 | Validation failure (invalid email format, password too short, missing nombre) — { errors: [{msg, param, ...}] } |
500 | Internal server error |
POST /api/auth/login
Authenticates an existing user and returns a short-lived access token plus a long-lived refresh token. The refresh token is persisted in theusers.refresh_token column so it can be validated and revoked.
Request body
The user’s registered email address.
The user’s plain-text password. Compared against the stored bcrypt hash.
Example request
Response — 200 OK
Signed JWT (HS256). Expires in 15 minutes. Include as
Authorization: Bearer <accessToken> on all protected routes.Signed JWT (HS256). Expires in 7 days. Stored in
users.refresh_token in the database for server-side validation. Send to POST /api/auth/refresh to obtain a new access token.Error codes
| Code | Meaning |
|---|---|
400 | Invalid credentials (user not found or wrong password) — { errors: [{ msg: "Credenciales inválidas" }] } |
400 | Validation failure (invalid email format, missing password) |
500 | Internal server error |
POST /api/auth/refresh
Exchanges a valid refresh token for a new 15-minute access token. The provided refresh token is verified cryptographically and cross-checked against the value stored in the database — so tokens invalidated via logout are rejected.Request body
The refresh token obtained from
POST /api/auth/login. Must be a valid, non-expired JWT that matches the value stored in the database.Example request
Response — 200 OK
A freshly signed access token with a new 15-minute expiry window.
Error codes
| Code | Meaning |
|---|---|
401 | Refresh token not provided in the request body |
403 | Refresh token is invalid, expired, or has been revoked (not found in DB) |
POST /api/auth/logout
Invalidates a refresh token by settingusers.refresh_token = NULL in the database. Subsequent calls to POST /api/auth/refresh using this token will return 403.
This endpoint only invalidates the refresh token server-side. Your client application is responsible for discarding the stored access token locally, since access tokens are stateless and cannot be revoked before they expire (15 min).
Request body
The refresh token to revoke. Must be the token currently associated with the user’s session.
Example request
Response — 200 OK
Confirmation string. Always
"Logout exitoso" on success.Error codes
| Code | Meaning |
|---|---|
400 | Refresh token was not included in the request body |
500 | Internal server error |
GET /api/auth/me
Returns the profile of the currently authenticated user. The access token is read directly from theAuthorization header — no request body is needed.
Request headers
| Header | Value |
|---|---|
Authorization | Bearer <accessToken> — the JWT obtained from POST /api/auth/login |
Example request
Response — 200 OK
Error codes
| Code | Meaning |
|---|---|
401 | No Authorization header, header is malformed, or the token has expired |
404 | Token is valid but the corresponding user no longer exists in the database |
Authentication Guide
Understand the JWT flow — how access and refresh tokens work together in PitchPro.
API Overview
See all available endpoints at a glance and learn about base URLs and error formats.