Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/titobrian97/Prueba-tecnica-ts-node---gestion-de-csv/llms.txt

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

This endpoint accepts a CSV file upload, validates that the file is present and has the correct MIME type (text/csv), parses it into an array of row objects using convert-csv-to-json with a comma delimiter, and stores the result in the server’s in-memory usersData array. The fully parsed dataset is returned in the response body.

Endpoint

POST /api/files

Request

The request must be sent as multipart/form-data. Include the CSV file in the file field.
file
file
required
The CSV file to upload. Must have the MIME type text/csv. The first row is treated as the header row — each column name becomes a key in the parsed row objects.

Example Request

curl -X POST http://localhost:3000/api/files \
  -F "file=@example.csv"

Success Response — HTTP 200

When the file is valid and parsed successfully, the server responds with HTTP 200 and a JSON body containing the full parsed dataset along with a confirmation message.
data
array
required
Array of row objects parsed from the CSV. Each object’s keys correspond to the CSV column headers (from the first row), and all values are strings.
message
string
required
Human-readable confirmation string. Always "El archivo se cargo correctamente" on success.

Example Success Response

{
  "data": [
    {
      "id": "1",
      "nombre": "Carlos",
      "apellido": "Mendez",
      "edad": "34",
      "email": "carlos.mendez@example.com",
      "ciudad": "Cancun",
      "pais": "Mexico",
      "telefono": "+52-998-123-4567"
    }
  ],
  "message": "El archivo se cargo correctamente"
}

Error Responses — HTTP 500

All error conditions return HTTP 500 with a JSON body. The data field is always an empty array on error.
Returned when the request does not include a file field in the multipart body.
{
  "data": [],
  "message": "file is required"
}
Returned when a file is attached but its MIME type is not text/csv (e.g., uploading a .xlsx or .txt file).
{
  "data": [],
  "message": "El archivo debe ser un csv"
}
Returned when the file passes MIME validation but convert-csv-to-json throws an exception while parsing the content.
{
  "data": [],
  "message": "Error parsing file"
}
Uploading a new CSV file replaces all data stored from any previous upload. The in-memory usersData array is overwritten entirely — there is no merge or append behaviour. Any search queries run after a new upload will operate only on the most recently uploaded file’s data.

Build docs developers (and LLMs) love