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.

Getting Mini Proyecto Backend NodeJS running on your machine takes about five minutes. By the end of these four steps you will have the project dependencies installed, a local MySQL database ready, and the Node.js entry point launched so you can begin implementing the server logic.

Prerequisites

Make sure the following are installed and accessible from your terminal before you begin:
  • Node.js v14 or laternodejs.org/en/download. Verify with node -v.
  • MySQL 5.7+ or MariaDB — a local server instance with a root account you can connect to without a password (matching the default project configuration), or credentials you can update.
  • npm — ships with Node.js. Verify with npm -v.

Setup Steps

1

Clone the Repository

Download the project source to your local machine:
git clone https://github.com/brandonvergara1220-del/Mini-Proyecto-Backend-NodeJS.git
cd Mini-Proyecto-Backend-NodeJS
2

Install Dependencies

The project has a single runtime dependency — mysql2 — declared in package.json. Install it with:
npm install
After installation your node_modules folder will contain mysql2 and its bundled bindings. You can confirm the installed version:
npm list mysql2
# mini-proyecto@1.0.0
# └── mysql2@3.22.5
The relevant section of package.json that drives this:
{
  "name": "mini-proyecto",
  "version": "1.0.0",
  "main": "index.html",
  "scripts": {
    "start": "node server.js"
  },
  "type": "commonjs",
  "dependencies": {
    "mysql2": "^3.22.5"
  }
}
3

Configure the Database

The project connects to a database named ejemploformulario on localhost using the root account with no password. Create the database in MySQL before starting the server:
CREATE DATABASE IF NOT EXISTS ejemploformulario;
Run that statement from the MySQL shell (mysql -u root) or any MySQL client such as MySQL Workbench or DBeaver.Here is the full conexion.js file that manages the connection — no changes are needed if your local MySQL matches the defaults above:
let mysql = require('mysql2');

// Conexión reutilizable a la base de datos del proyecto.
let conexion = mysql.createConnection({
  host: "localhost",
  database: "ejemploformulario",
  user: "root",
  password: ""
});

conexion.connect(function(error) {
  if (error) {
    throw error;
  } else {
    console.log("Conexión exitosa a la base de datos");
  }
});

module.exports = conexion;
If your MySQL root account has a password, update the password field in conexion.js before moving to the next step.
4

Implement server.js and Start the Server

server.js ships as an empty file — writing the HTTP server logic is the hands-on goal of this SENA ADSO exercise. Your implementation must:
  1. require('./conexion') to obtain the shared MySQL connection.
  2. Listen on a local port (for example 3000).
  3. Serve index.html on GET /.
  4. Parse the URL-encoded form body and insert nombre and apellido on POST /recuperardatos.
Once you have written your implementation, start the application with:
npm start
This runs node server.js. If conexion.js is required correctly, a successful database connection prints:
Conexión exitosa a la base de datos
Then open your browser and navigate to http://localhost:3000 (or whichever port your implementation binds to) to see the Registro Tienda Parque 100 HTML form. Fill in the Nombre and Apellido fields and click Enviar to POST the form data to /recuperardatos.
server.js is the student’s implementation file. The repository ships it as an empty file — writing the HTTP server logic (listening on a port, routing GET / to serve index.html, and handling POST /recuperardatos to insert form data) is the hands-on part of the SENA ADSO exercise. conexion.js and index.html are provided as ready-to-use building blocks.
Hard-coding credentials (user: "root", password: "") is fine for a local learning exercise, but build the habit early of loading secrets from environment variables. Install the dotenv package and replace the literal values with process.env.DB_USER and process.env.DB_PASSWORD so credentials never end up committed to source control.

Build docs developers (and LLMs) love