Skip to main content

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.

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.

What the Project Does

The project has three moving parts that work together to form a complete, if minimal, backend:
  • HTTP serverserver.js is the entry point started with npm 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, serving index.html, and handling the POST /recuperardatos form submission.
  • MySQL connectionconexion.js uses the mysql2 package to open a persistent, reusable connection to a local MySQL database named ejemploformulario. The connection is exported as a CommonJS module so server.js can require it and run queries once the student implements the server logic.
  • HTML registration formindex.html renders a simple “Registro Tienda Parque 100” form with two fields (nombre and apellido) and a submit button. The form posts to /recuperardatos for the server to process.

Tech Stack

LayerTechnologyNotes
RuntimeNode.js v14+CommonJS module system ("type": "commonjs")
Database drivermysql2 ^3.22.5Callback-based createConnection API
DatabaseMySQL 5.7+ or MariaDBLocal instance, database ejemploformulario
FrontendPlain HTML5No framework; lang="es" (Spanish)
Package managernpmnpm start launches node server.js

Key Concepts

Understanding three short files teaches a disproportionate amount about how Node.js backends work: CommonJS modulesconexion.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 connectionmysql.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.
Before running the project in any shared or networked environment, replace the hard-coded credentials in conexion.js (user: "root", password: "") with values loaded from environment variables or a .env file. This keeps secrets out of source control and is the first habit worth building — even on learning projects.

Build docs developers (and LLMs) love