TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/nelrondon/backend-proyecto-estructuras/llms.txt
Use this file to discover all available pages before exploring further.
GET /api/ endpoint returns the complete profile of the currently authenticated user. Once a valid token cookie is present in the request — issued automatically during login or registration — this endpoint queries the database for the corresponding user record and returns all profile fields: id, name, email, phone, role, username, and last_login.
This endpoint requires authentication. The
token cookie must be present and
valid. It is set automatically when you call POST /api/login or POST /api/register and expires after 7 days.Endpoint
| Method | Path | Auth Required |
|---|---|---|
GET | /api/ | ✅ Yes |
Authentication
This endpoint is protected by theauthRequired middleware. The middleware reads the token cookie from the incoming request, verifies the JWT signature, and attaches the decoded payload (including id) to req.user. No request body or query parameters are needed.
| Cookie | Type | Description |
|---|---|---|
token | string | JWT issued by POST /api/login or POST /api/register. httpOnly, secure, sameSite: none. |
Request
No request body is required for this endpoint.How It Works
authRequiredmiddleware decodes thetokencookie and setsreq.user.id.AuthController.getcallsUserModel.find(id), which executes:- If a matching row is found, the controller returns the user’s profile fields as JSON.
- If no row is found, a
404response is returned.
Response Fields
The unique UUID of the user, generated at registration time via
randomUUID().The user’s full display name as provided during registration.
The user’s email address. Must be unique across all accounts.
The user’s phone number. Must be unique across all accounts.
The user’s assigned role. Returns
null if no role has been assigned to the account.The user’s unique username used for login. Must be unique across all accounts.
ISO 8601 timestamp of the user’s most recent successful login, updated by
POST /api/login.Success Response
Status:200 OK
Error Responses
| Status | Body | Cause |
|---|---|---|
401 | { "message": "No Token, Unauthorized" } | No token cookie was included in the request. |
403 | { "message": "Invalid Token" } | The token cookie is present but has an invalid signature or has expired. |
404 | { "message": "Usuario no encontrado" } | The user ID decoded from the JWT does not match any record in the database. |