Skip to main content

Documentation 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.

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 — the 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 in package.json:
PackageVersionPurpose
express^5.2.1HTTP server framework — handles routing, middleware chaining, and the request/response lifecycle.
cors^2.8.6Cross-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.7Node.js path utilities for resolving file-system paths, useful when serving static assets.
package.json
{
  "name": "backend",
  "version": "1.0.0",
  "type": "commonjs",
  "main": "index.js",
  "dependencies": {
    "cors": "^2.8.6",
    "express": "^5.2.1",
    "path": "^0.12.7"
  }
}

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 on localhost: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:
// Reference template — index.js does not yet exist in the repository
const cors = require('cors');
const express = require('express');

const app = express();
app.use(cors());
In production, restrict the CORS origin to your deployed frontend domain. Using cors() with no options allows requests from any origin, which is a security risk for an API that handles real user data.
app.use(cors({ origin: 'https://directorio.udc.example.com' }));

Starting the Server

Once index.js has been created, the server has no npm start script defined, so it is launched directly with Node.js:
cd BACKEND
node index.js
The server process will start and begin accepting connections on port 3000. Stop it at any time with Ctrl + C.
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.
# Install nodemon as a dev dependency
npm install --save-dev nodemon

# Run with auto-reload
npx nodemon index.js

CommonJS Module System

The package.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:
// Reference template — CommonJS module loading pattern for the backend
const express = require('express');
const cors = require('cors');
const path = require('path');
This is the opposite of the frontend’s "type": "module" setting. The two projects are entirely independent, so each can use whichever module system suits it best without any conflict.

Build docs developers (and LLMs) love