Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/LizandroCanul/back_sdo/llms.txt

Use this file to discover all available pages before exploring further.

Overview

These endpoints allow users to manage their favorite obras (public works projects). Users can add obras to their favorites, remove them, and retrieve their complete list of favorites with pagination.
Owner Only - Users can only manage their own favorites. Attempting to modify another user’s favorites will result in a 403 Forbidden error.

Add Favorite

curl -X POST https://api.yucatan.gob.mx/users/550e8400-e29b-41d4-a716-446655440000/favorites/1234 \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"
Add an obra to the user’s favorites list.

Path Parameters

id
string (UUID)
required
The user’s unique identifier. Must match the authenticated user’s ID.
obraId
integer
required
The ID of the obra to add to favorites.

Authentication

Requires a valid JWT token. The authenticated user’s ID must match the :id parameter.

Response

id
integer
Unique identifier for the favorite record
userId
string (UUID)
The user’s ID
obraId
integer
The obra’s ID
createdAt
string (ISO 8601)
Timestamp when the favorite was added

Example Response

201 Created
{
  "id": 1,
  "userId": "550e8400-e29b-41d4-a716-446655440000",
  "obraId": 1234,
  "createdAt": "2024-03-03T17:00:00.000Z"
}
400 Bad Request - Already in Favorites
{
  "statusCode": 400,
  "message": "Esta obra ya está en tus favoritas"
}
403 Forbidden
{
  "statusCode": 403,
  "message": "No puedes modificar los favoritos de otro usuario."
}
404 Not Found
{
  "statusCode": 404,
  "message": "Usuario no encontrado"
}

Authorization Rules

  • The authenticated user’s userId must match the :id path parameter
  • Admins do NOT have special privileges for this endpoint
  • The user must exist in the database
  • The obra cannot already be in the user’s favorites (checked via unique constraint)
See implementation in /home/daytona/workspace/source/src/users/users.controller.ts:81

Remove Favorite

curl -X DELETE https://api.yucatan.gob.mx/users/550e8400-e29b-41d4-a716-446655440000/favorites/1234 \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"
Remove an obra from the user’s favorites list.

Path Parameters

id
string (UUID)
required
The user’s unique identifier. Must match the authenticated user’s ID.
obraId
integer
required
The ID of the obra to remove from favorites.

Authentication

Requires a valid JWT token. The authenticated user’s ID must match the :id parameter.

Response

message
string
Confirmation message: “Obra removida de favoritas”

Example Response

200 Success
{
  "message": "Obra removida de favoritas"
}
403 Forbidden
{
  "statusCode": 403,
  "message": "No puedes modificar los favoritos de otro usuario."
}
404 Not Found
{
  "statusCode": 404,
  "message": "Esta obra no está en tus favoritas"
}

Authorization Rules

  • The authenticated user’s userId must match the :id path parameter
  • Admins do NOT have special privileges for this endpoint
  • The obra must exist in the user’s favorites to be removed
See implementation in /home/daytona/workspace/source/src/users/users.controller.ts:94

Get User Favorites

curl -X GET "https://api.yucatan.gob.mx/users/550e8400-e29b-41d4-a716-446655440000/favorites?limit=10&page=1" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"
Retrieve a paginated list of the user’s favorite obras with full obra details including related entities.

Path Parameters

id
string (UUID)
required
The user’s unique identifier

Query Parameters

limit
integer
default:"10"
Number of items per page (optional)
page
integer
default:"1"
Page number (optional, 1-indexed)

Authentication

Requires a valid JWT token. The authenticated user must be either:
  • The owner of the favorites (user.userId === id)
  • An admin (can view any user’s favorites)

Response

data
array
Array of full obra objects with all related data
meta
object
Pagination metadata

Example Response

200 Success
{
  "data": [
    {
      "id": 1234,
      "nombre": "Construcción de Carretera",
      "descripcion": "Carretera de 10km",
      "municipio": {
        "id": 1,
        "nombre": "Mérida"
      },
      "dependencia": {
        "id": 5,
        "nombre": "Secretaría de Obras Públicas"
      },
      "ejercicioFiscal": {
        "id": 2024,
        "anio": 2024
      },
      "estatusObra": {
        "id": 2,
        "nombre": "En progreso"
      },
      "tipoProyecto": {
        "id": 3,
        "nombre": "Infraestructura"
      }
    }
  ],
  "meta": {
    "totalItems": 25,
    "itemCount": 10,
    "itemsPerPage": 10,
    "totalPages": 3,
    "currentPage": 1
  }
}
403 Forbidden
{
  "statusCode": 403,
  "message": "No tienes permiso para ver los favoritos de otro usuario."
}
404 Not Found
{
  "statusCode": 404,
  "message": "Usuario no encontrado"
}

Authorization Rules

  • Admin users: Can view any user’s favorites
  • Regular users: Can only view their own favorites (user.userId === id)
  • Mismatch: If a regular user tries to view another user’s favorites, returns 403 Forbidden
See implementation in /home/daytona/workspace/source/src/users/users.controller.ts:109 The response includes full obra objects with the following TypeORM relations loaded:
  • obra.municipio - Municipality where the obra is located
  • obra.dependencia - Government department managing the obra
  • obra.ejercicioFiscal - Fiscal year of the obra
  • obra.estatusObra - Current status of the obra
  • obra.tipoProyecto - Type/category of the project
Favorites are ordered by createdAt in descending order (newest first).

Build docs developers (and LLMs) love