La API RESTful de usuarios con operaciones CRUD (Crear, Leer, Actualizar, Eliminar) con conexión a una base de datos en PostgreSQL.
🔗 appusuarios-backend.onrender.com/users
Stack: NodeJs, ExpressJs, Cors, Pg, dontEnv.
git clone https://github.com/joche-dev/appusuarios-backend.git
cd appusuarios-backend
npm install
To run this project, you will need to add the following environment variables to your .env file
PGUSER="postgres"
PGHOST="localhost"
PGPASSWORD="postgres"
PGDATABASE="app_usuarios"
PGPORT=5432
PORT = 4000
To run this project, you will need to create data base in pgAdmin or psql.
CREATE DATABASE app_usuarios;
CREATE TABLE IF NOT EXISTS users (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL UNIQUE,
phone VARCHAR(20) NOT NULL
region VARCHAR(100) NOT NULL,
commune VARCHAR(100) NOT NULL
);
npm run start
Description: Retrieves a list of all users.
Response:
{
"ok": true,
"data": [
{
"id": 1,
"name": "Juan Perez",
"email": "[email protected]",
"phone": "912345678",
"region": "Metropolitana de Santiago",
"commune": "La Florida"
},
...
]
}
Description: Retrieves a specific user by their ID.
Path Parameters: 🆔 The unique identifier of the user (integer)
Response:
{
"ok": true,
"data": {
"id": 1,
"name": "Juan Perez",
"email": "[email protected]",
"phone": "912345678",
"region": "Metropolitana de Santiago",
"commune": "La Florida"
}
}
Description: Creates a new user.
Request Body:
{
"name": "Juan Perez",
"email": "[email protected]",
"phone": "912345678",
"region": "Metropolitana de Santiago",
"commune": "La Florida"
}
Response:
{
"ok": true,
"message": "Registro del usuario exitoso."
}
Description: Updates an existing user.
Path Parameters: 🆔 The unique identifier of the user (integer)
Request Body:
{
"name": "Juan Perez",
"email": "[email protected]",
"phone": "912345678",
"region": "Metropolitana de Santiago",
"commune": "La Florida"
}
Response:
{
"ok": true,
"message": "Actualización de usuario exitoso."
}
Description: Deletes a specific user by their ID.
Path Parameters: 🆔 The unique identifier of the user (integer)
Response:
{
"ok": true,
"message": "Usuario eliminado con éxito."
}