Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Medinaallan/ContabilidadISV/llms.txt

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

All file endpoints require a valid JWT token sent in the Authorization: Bearer <token> header. Files are uploaded as multipart/form-data and stored in the server-side uploads/ directory with a UUID-prefixed filename to prevent collisions. Once uploaded, an Excel workbook is automatically parsed with SheetJS (xlsx): each sheet is converted to JSON, numeric column totals are computed, and the resulting data is persisted as a consolidated reference that can be retrieved later via GET /api/files/data/:fileId.
Only .xlsx and .xls files are accepted. PDFs, CSVs, and all other file types are rejected with 400 Bad Request. The server-side size cap is controlled by the MAX_FILE_SIZE environment variable and defaults to 10 MB.

POST /api/files/upload

Uploads an Excel workbook. The request must be multipart/form-data. The file field name must be excelFile. Request
excelFile
file
required
The Excel workbook to upload. Accepted MIME types: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet (.xlsx) and application/vnd.ms-excel (.xls). Maximum size: 10 MB.
Response201 Created
message
string
Confirmation string: "Archivo subido exitosamente".
file
object
Metadata for the uploaded file.
curl -X POST https://your-host/api/files/upload \
  -H "Authorization: Bearer $TOKEN" \
  -F "excelFile=@/path/to/consolidacion_junio.xlsx"
{
  "message": "Archivo subido exitosamente",
  "file": {
    "id": 42,
    "original_name": "consolidacion_junio.xlsx",
    "filename": "1720612800000_3f2e1a4b-…xlsx",
    "filesize": 204800,
    "upload_date": "2024-07-10T14:00:00.000Z"
  }
}
Error codes
StatusReason
400No file provided, or file type is not .xlsx/.xls
413File exceeds the 10 MB size limit
401Missing or invalid JWT

GET /api/files/history

Returns a list of all uploaded files with their metadata. Admins see every file from every user; non-admin users see only their own uploads. Query parameters
userId
number
(Admin only) Filter results to files uploaded by a specific user ID. Ignored for non-admin callers.
Response
files
array
Array of file metadata objects ordered by upload date (most recent first).
curl -X GET "https://your-host/api/files/history" \
  -H "Authorization: Bearer $TOKEN"
{
  "files": [
    {
      "id": 42,
      "original_name": "consolidacion_junio.xlsx",
      "filename": "1720612800000_3f2e1a4b-…xlsx",
      "filesize": 204800,
      "upload_date": "2024-07-10T14:00:00.000Z",
      "username": "contadora"
    }
  ]
}

GET /api/files/download/:fileId

Downloads the raw Excel file identified by fileId as a binary file attachment. Admins can download any file; non-admin users can only download files they uploaded themselves. Path parameter
fileId
number
required
The numeric ID of the file to download (from the history list or upload response).
Response — binary file stream (Content-Disposition: attachment). The server calls res.download() which sets the correct headers so the browser or curl client receives the file under its original name.
curl -X GET https://your-host/api/files/download/42 \
  -H "Authorization: Bearer $TOKEN" \
  -O -J
Error codes
StatusReason
403Non-admin user trying to download another user’s file
404File record not found in the database, or physical file missing on disk

GET /api/files/data/:fileId

Returns the parsed and consolidated data extracted from the uploaded Excel workbook. The data was pre-processed on upload — each worksheet is represented as an object with row data and computed numeric column totals. Path parameter
fileId
number
required
The numeric ID of the file whose consolidated data to retrieve.
Response
file
object
Summary of the source file.
data
array
Array of consolidated sheet objects. Each entry corresponds to one worksheet in the workbook and contains:
curl -X GET https://your-host/api/files/data/42 \
  -H "Authorization: Bearer $TOKEN"
{
  "file": {
    "id": 42,
    "original_name": "consolidacion_junio.xlsx",
    "upload_date": "2024-07-10T14:00:00.000Z"
  },
  "data": [
    {
      "sheet_name": "Generales",
      "row_data": [
        { "RTN": "08011985123456", "Empresa": "Café del Valle", "Ventas": "120000" }
      ],
      "totals": {
        "totalRows": 1,
        "numericColumns": {
          "Ventas": { "sum": 120000, "count": 1, "min": 120000, "max": 120000, "average": 120000 }
        },
        "summary": {
          "headers": ["RTN", "Empresa", "Ventas"],
          "totalDataRows": 1,
          "numericColumnsCount": 1
        }
      }
    }
  ]
}
Error codes
StatusReason
403Non-admin user trying to view another user’s file data
404File record not found

Build docs developers (and LLMs) love