The Directorio UDC backend is a lightweight Express.js 5 HTTP server that acts as the data layer for the React SPA. It runs on Node.js using the CommonJS module system and is intentionally minimal — theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Minogar28/DIRECTORIO_UDC/llms.txt
Use this file to discover all available pages before exploring further.
package.json declares the three runtime dependencies needed to wire up middleware and route handlers, keeping the project easy to navigate and extend. The server is intended to listen on port 3000 and will be the single origin the frontend calls for all data operations.
The
BACKEND/ directory currently contains only package.json and package-lock.json. The index.js entry point has not yet been committed. Code blocks in this page are reference templates showing the intended implementation.Dependencies
The backend declares three runtime dependencies inpackage.json:
| Package | Version | Purpose |
|---|---|---|
express | ^5.2.1 | HTTP server framework — handles routing, middleware chaining, and the request/response lifecycle. |
cors | ^2.8.6 | Cross-Origin Resource Sharing middleware — required so the Vite dev server at port 5173 can call the API at port 3000 without browser security restrictions. |
path | ^0.12.7 | Node.js path utilities for resolving file-system paths, useful when serving static assets. |
package.json
CORS Configuration
The browser’s Same-Origin Policy blocks JavaScript from making requests to a different origin (protocol + host + port). During development the React app is served by Vite onlocalhost:5173 while the API runs on localhost:3000 — a different port means a different origin, so without CORS headers the browser would reject every API call.
The cors package solves this by injecting the appropriate Access-Control-Allow-* response headers. The following reference template shows the intended setup in index.js. Calling cors() with no arguments applies permissive defaults that allow all origins:
Starting the Server
Onceindex.js has been created, the server has no npm start script defined, so it is launched directly with Node.js:
The backend has no
start or dev script defined in package.json. For development with auto-reload on file changes, consider installing nodemon and running nodemon index.js instead.CommonJS Module System
Thepackage.json declares "type": "commonjs", which means Node.js will treat every .js file in the project as a CommonJS module. Modules are loaded with require() and exported with module.exports, rather than the ESM import/export syntax used in the frontend. The following reference snippet shows how the three dependencies are loaded in a typical index.js entry point:
"type": "module" setting. The two projects are entirely independent, so each can use whichever module system suits it best without any conflict.