Mini Proyecto Backend NodeJS is a minimal learning project built for the SENA ADSO program (activity GA7-220501096-AA2-EV02). It wires together a Node.js HTTP server, a MySQL database connection, and a plain HTML registration form to demonstrate the core loop of a backend application: serve a page, accept user input, and persist it to a database — all without a framework.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/brandonvergara1220-del/Mini-Proyecto-Backend-NodeJS/llms.txt
Use this file to discover all available pages before exploring further.
What the Project Does
The project has three moving parts that work together to form a complete, if minimal, backend:- HTTP server —
server.jsis the entry point started withnpm start(node server.js). The repository ships it as an empty file — students write the HTTP server logic as the hands-on part of the exercise. It is responsible for listening on a port, routing requests, servingindex.html, and handling thePOST /recuperardatosform submission. - MySQL connection —
conexion.jsuses themysql2package to open a persistent, reusable connection to a local MySQL database namedejemploformulario. The connection is exported as a CommonJS module soserver.jscanrequireit and run queries once the student implements the server logic. - HTML registration form —
index.htmlrenders a simple “Registro Tienda Parque 100” form with two fields (nombreandapellido) and a submit button. The form posts to/recuperardatosfor the server to process.
Tech Stack
| Layer | Technology | Notes |
|---|---|---|
| Runtime | Node.js v14+ | CommonJS module system ("type": "commonjs") |
| Database driver | mysql2 ^3.22.5 | Callback-based createConnection API |
| Database | MySQL 5.7+ or MariaDB | Local instance, database ejemploformulario |
| Frontend | Plain HTML5 | No framework; lang="es" (Spanish) |
| Package manager | npm | npm start launches node server.js |
Key Concepts
Understanding three short files teaches a disproportionate amount about how Node.js backends work: CommonJS modules —conexion.js ends with module.exports = conexion. Once students implement server.js, they pull the connection in with require('./conexion'). This is the standard Node.js module pattern ("type": "commonjs" in package.json).
mysql2 connection — mysql.createConnection({ host, database, user, password }) opens a TCP socket to MySQL. The subsequent conexion.connect(callback) verifies the socket and logs "Conexión exitosa a la base de datos" on success, or throws on failure. Exporting the live connection object means every module that requires it shares the same socket.
HTML form POST — The <form action="recuperardatos" method="post"> tag tells the browser to send a URL-encoded body to POST /recuperardatos when the user clicks Enviar. The server implementation must parse that body to extract nombre and apellido before writing them to the database.
This project is a SENA ADSO learning exercise (GA7-220501096-AA2-EV02). Its goal is to make backend concepts concrete and approachable, not to serve as production-ready code.
server.js ships empty — writing its logic is the core task students complete.Explore the Project
Quickstart
Install dependencies, configure MySQL, and run the server locally in four steps.
Structure Overview
Understand what every file does and how the pieces connect to each other.