The backend is a single-file Express 5 server (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.
server.ts) that exposes two REST endpoints — one for uploading and parsing a CSV file and one for searching the parsed records. It is written in TypeScript and executed directly by ts-node, so there is no separate compile step. All parsed data lives in a module-level array in memory, which means the dataset is fast to query but is discarded whenever the process restarts.
Key Dependencies
Runtime dependencies
Runtime dependencies
| Package | Version | Role |
|---|---|---|
express | ^5.2.1 | HTTP server framework — handles routing, middleware, and request/response lifecycle. |
multer | ^2.1.1 | Multipart form-data middleware — receives the uploaded file and exposes its raw bytes as req.file.buffer. |
convert-csv-to-json | ^4.36.0 | Converts a UTF-8 CSV string to Array<Record<string, string>> using a fluent API. |
cors | ^2.8.6 | Express middleware that sets CORS headers so the Vite frontend on port 4000 can reach the API on port 3000. |
cross-env | ^10.1.0 | Sets the PORT environment variable in a cross-platform way inside npm scripts. |
ts-node | ^10.9.2 | Runs server.ts directly without a prior tsc compilation step. |
In-Memory Data Model
The entire parsed dataset is held in a single module-level variable declared at the top ofserver.ts:
Upload Middleware
multer is configured with memoryStorage so that the uploaded file is never written to disk:
upload.single("file") is applied to a route, multer reads the multipart body and attaches the result to req.file. The raw bytes of the file are accessible via req.file.buffer as a Node.js Buffer. The route handler decodes this buffer to a UTF-8 string with Buffer.from(file.buffer).toString("utf-8") before passing it to the CSV parser. Using memory storage avoids the need to manage temporary files on disk and keeps the server stateless at the OS level.
Full Server Source
Endpoints
POST /api/files — Upload and parse a CSV
POST /api/files — Upload and parse a CSV
Request — The result is assigned to
multipart/form-data with a field named file.Validation- Returns
500with{ data: [], message: "file is required" }if no file is present. - Returns
500with{ data: [], message: "El archivo debe ser un csv" }iffile.mimetypeis not"text/csv".
usersData, replacing any prior data.Success response — 200 OKGET /api/users?q= — Search parsed records
GET /api/users?q= — Search parsed records
Query parameters
ProcessingThe search is case-insensitive and spans every column value in every row:Success response — An empty
| Parameter | Required | Description |
|---|---|---|
q | Yes | Search term. Returns 500 with { message: "No hay parametro de busqueda" } if omitted. |
200 OKdata array is returned when no rows match — this is not treated as an error by the backend.Environment Configuration
The server reads the port from thePORT environment variable and falls back to 3000 if it is not set:
Scripts
Both npm scripts usecross-env to ensure the environment variable is set consistently on Windows, macOS, and Linux:
npm run dev and npm start are identical — both launch ts-node server.ts with PORT=3000. There is no separate watch mode or hot-reload; the process must be restarted manually after source changes.