Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ yarn-debug.log*
yarn-error.log*
lerna-debug.log*

*node_modules*
*/node_modules/*
*.env

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
Expand Down
107 changes: 106 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,106 @@
# plantilla-proyecto-final
| Integrantes | Rol Principal |
| :--- | :--- |
| **ESPINOZA PILLASAGUA JIMER SAMUEL** | Lead Backend Developer & DB Admin |
| **CHAVEZ FLECHER MAURO YASMANI** | Lead Backend Developer & DB Admin |
| **MENDOZA PALMA BORIS SAMUEL** | Lead Backend Developer & DB Admin |
| **NAVARRETE BRIONES ISAAC ELIASIB** | Lead Backend Developer & DB Admin |
| **GILER MIELES JESUS ALFREDO** | Lead Backend Developer & DB Admin |

# 🎮 VR-Store Inventory API 🚀

![Backend Status](https://img.shields.io/badge/Backend-Running-brightgreen?style=for-the-badge&logo=node.js)
![Database](https://img.shields.io/badge/Database-Sequelize_SQLite-blue?style=for-the-badge&logo=sqlite)

Bienvenido al sistema de gestión de inventario para la tienda de **Realidad Virtual y Videojuegos**. Esta API permite controlar el stock, precios y categorías de dispositivos de última generación.

---

## 🛠️ Stack Tecnológico

| Tecnología | Uso |
| :--- | :--- |
| **Node.js** | Entorno de ejecución |
| **Express** | Framework de servidor y rutas |
| **Sequelize** | ORM para manejo de Base de Datos |
| **CORS** | Intercambio de recursos de origen cruzado |
| **Dotenv** | Manejo de variables de entorno |

---

## ⚙️ Configuración e Instalación

### 1. Clonar y Preparar
```bash
# Navegar a tu rama de grupo
git checkout nombre-de-tu-grupo

# Instalar dependencias
npm install

### 📋 Estructura de Datos (JSON)
Cada objeto `Producto` en nuestra base de datos tiene la siguiente estructura:

| Campo | Tipo | Descripción |
| :--- | :--- | :--- |
| `id` | Integer | Identificador único (Auto-incremental) |
| `nombre` | String | Nombre del producto (Obligatorio) |
| `cantidad` | Integer | Stock disponible (Default: 0) |
| `precio` | Float | Precio unitario (Obligatorio) |
| `categoria` | String | Categoría del producto |

---

### 🚀 Operaciones y Pruebas

#### 1. Listar Productos (READ)
* **Método:** `GET`
* **Endpoint:** `/api/v1/productos`
* **Acción:** Recupera todos los registros de la base de datos.
* **Prueba en PowerShell:**
```powershell
Invoke-RestMethod -Method Get -Uri "http://localhost:8080/api/v1/productos"
```

#### 2. Crear Nuevo Registro (CREATE)
* **Método:** `POST`
* **Endpoint:** `/api/v1/productos`
* **Acción:** Inserta un nuevo producto. El servidor responde con el objeto creado y su ID.
* **Prueba en PowerShell:**
```powershell
$postData = @{ nombre="Apple Vision Pro"; cantidad=2; precio=3499.00; categoria="Realidad Virtual" } | ConvertTo-Json
Invoke-RestMethod -Method Post -Uri "http://localhost:8080/api/v1/productos" -ContentType "application/json" -Body $postData
```

#### 3. Actualizar Información (UPDATE)
* **Método:** `PUT`
* **Endpoint:** `/api/v1/productos/:id`
* **Acción:** Actualiza campos específicos de un producto existente.
* **Prueba en PowerShell:**
```powershell
$updateData = @{ precio=449.99; cantidad=20 } | ConvertTo-Json
Invoke-RestMethod -Method Put -Uri "http://localhost:8080/api/v1/productos/1" -ContentType "application/json" -Body $updateData
```

#### 4. Eliminar Registro (DELETE)
* **Método:** `DELETE`
* **Endpoint:** `/api/v1/productos/:id`
* **Acción:** Borra permanentemente el producto especificado por el ID.
* **Prueba en PowerShell:**
```powershell
Invoke-RestMethod -Method Delete -Uri "http://localhost:8080/api/v1/productos/2"
```

---

### 🚥 Códigos de Estado HTTP
Nuestra API responde con los siguientes estados estándar para confirmar el éxito o error de la operación:



* ✅ **200 OK:** La solicitud fue exitosa.
* ✨ **201 Created:** El producto se creó correctamente.
* ❌ **400 Bad Request:** Los datos enviados son inválidos.
* 🔍 **404 Not Found:** El ID del producto no existe.
* ⚠️ **500 Internal Server Error:** Error inesperado en el servidor.

---
13 changes: 9 additions & 4 deletions backend/.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
PORT=3001
PORT=8080
DB_HOST=grupofmo.com
DB_USER=pweb
DB_PASSWORD=Pru3b4.2025
DB_NAME=pweb
DB_USER=pwebg2
DB_PASSWORD=pwebg2.2025
DB_NAME=pwebg2
DB_PORT=3306
DB_LOG=false
#PORT=8080
SSL_ENABLED=false
SSL_KEY_PATH=/etc/letsencrypt/live/pweb.grupofmo.com/privkey.pem
SSL_CERT_PATH=/etc/letsencrypt/live/pweb.grupofmo.com/fullchain.pem
106 changes: 106 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
| Integrantes | Rol Principal |
| :--- | :--- |
| **ESPINOZA PILLASAGUA JIMER SAMUEL** | Lead Backend Developer & DB Admin |
| **CHAVEZ FLECHER MAURO YASMANI** | Lead Backend Developer & DB Admin |
| **MENDOZA PALMA BORIS SAMUEL** | Lead Backend Developer & DB Admin |
| **NAVARRETE BRIONES ISAAC ELIASIB** | Lead Backend Developer & DB Admin |
| **GILER MIELES JESUS ALFREDO** | Lead Backend Developer & DB Admin |

# 🎮 VR-Store Inventory API 🚀

![Backend Status](https://img.shields.io/badge/Backend-Running-brightgreen?style=for-the-badge&logo=node.js)
![Database](https://img.shields.io/badge/Database-Sequelize_SQLite-blue?style=for-the-badge&logo=sqlite)

Bienvenido al sistema de gestión de inventario para la tienda de **Realidad Virtual y Videojuegos**. Esta API permite controlar el stock, precios y categorías de dispositivos de última generación.

---

## 🛠️ Stack Tecnológico

| Tecnología | Uso |
| :--- | :--- |
| **Node.js** | Entorno de ejecución |
| **Express** | Framework de servidor y rutas |
| **Sequelize** | ORM para manejo de Base de Datos |
| **CORS** | Intercambio de recursos de origen cruzado |
| **Dotenv** | Manejo de variables de entorno |

---

## ⚙️ Configuración e Instalación

### 1. Clonar y Preparar
```bash
# Navegar a tu rama de grupo
git checkout nombre-de-tu-grupo

# Instalar dependencias
npm install

### 📋 Estructura de Datos (JSON)
Cada objeto `Producto` en nuestra base de datos tiene la siguiente estructura:

| Campo | Tipo | Descripción |
| :--- | :--- | :--- |
| `id` | Integer | Identificador único (Auto-incremental) |
| `nombre` | String | Nombre del producto (Obligatorio) |
| `cantidad` | Integer | Stock disponible (Default: 0) |
| `precio` | Float | Precio unitario (Obligatorio) |
| `categoria` | String | Categoría del producto |

---

### 🚀 Operaciones y Pruebas

#### 1. Listar Productos (READ)
* **Método:** `GET`
* **Endpoint:** `/api/v1/productos`
* **Acción:** Recupera todos los registros de la base de datos.
* **Prueba en PowerShell:**
```powershell
Invoke-RestMethod -Method Get -Uri "http://localhost:8080/api/v1/productos"
```

#### 2. Crear Nuevo Registro (CREATE)
* **Método:** `POST`
* **Endpoint:** `/api/v1/productos`
* **Acción:** Inserta un nuevo producto. El servidor responde con el objeto creado y su ID.
* **Prueba en PowerShell:**
```powershell
$postData = @{ nombre="Apple Vision Pro"; cantidad=2; precio=3499.00; categoria="Realidad Virtual" } | ConvertTo-Json
Invoke-RestMethod -Method Post -Uri "http://localhost:8080/api/v1/productos" -ContentType "application/json" -Body $postData
```

#### 3. Actualizar Información (UPDATE)
* **Método:** `PUT`
* **Endpoint:** `/api/v1/productos/:id`
* **Acción:** Actualiza campos específicos de un producto existente.
* **Prueba en PowerShell:**
```powershell
$updateData = @{ precio=449.99; cantidad=20 } | ConvertTo-Json
Invoke-RestMethod -Method Put -Uri "http://localhost:8080/api/v1/productos/1" -ContentType "application/json" -Body $updateData
```

#### 4. Eliminar Registro (DELETE)
* **Método:** `DELETE`
* **Endpoint:** `/api/v1/productos/:id`
* **Acción:** Borra permanentemente el producto especificado por el ID.
* **Prueba en PowerShell:**
```powershell
Invoke-RestMethod -Method Delete -Uri "http://localhost:8080/api/v1/productos/2"
```

---

### 🚥 Códigos de Estado HTTP
Nuestra API responde con los siguientes estados estándar para confirmar el éxito o error de la operación:



* ✅ **200 OK:** La solicitud fue exitosa.
* ✨ **201 Created:** El producto se creó correctamente.
* ❌ **400 Bad Request:** Los datos enviados son inválidos.
* 🔍 **404 Not Found:** El ID del producto no existe.
* ⚠️ **500 Internal Server Error:** Error inesperado en el servidor.

---
16 changes: 16 additions & 0 deletions backend/db/db.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { Sequelize } = require("sequelize");
require("dotenv").config();

const sequelize = new Sequelize(
process.env.DB_NAME,
process.env.DB_USER,
process.env.DB_PASSWORD,
{
host: process.env.DB_HOST,
port: Number(process.env.DB_PORT || 3306),
dialect: "mariadb",
logging: false, // cámbialo a console.log si quieres ver SQL
}
);

module.exports = { sequelize };
22 changes: 22 additions & 0 deletions backend/models/Producto.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const { DataTypes } = require("sequelize");
const { sequelize } = require("../db/db");

const Producto = sequelize.define("Producto", {
nombre: {
type: DataTypes.STRING,
allowNull: false,
},
cantidad: {
type: DataTypes.INTEGER,
defaultValue: 0,
},
precio: {
type: DataTypes.FLOAT,
allowNull: false,
},
categoria: {
type: DataTypes.STRING,
},
});

module.exports = Producto;
22 changes: 22 additions & 0 deletions backend/models/Task.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const { DataTypes } = require("sequelize");
const { sequelize } = require("../db/db");

const Task = sequelize.define(
"Task",
{
id: { type: DataTypes.INTEGER, autoIncrement: true, primaryKey: true },
title: { type: DataTypes.STRING(120), allowNull: false },
description: { type: DataTypes.STRING(255), allowNull: true },
status: {
type: DataTypes.ENUM("PENDIENTE", "EN_PROGRESO", "HECHA"),
allowNull: false,
defaultValue: "PENDIENTE"
}
},
{
tableName: "tasks",
timestamps: true
}
);

module.exports = { Task };
17 changes: 17 additions & 0 deletions backend/models/Usuario.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const { DataTypes } = require("sequelize");
const { sequelize } = require("../db/db");

const Usuario = sequelize.define(
"Usuario",
{
id: { type: DataTypes.INTEGER, autoIncrement: true, primaryKey: true },
nombre: { type: DataTypes.STRING(80), allowNull: false },
email: { type: DataTypes.STRING(120), allowNull: false, unique: true },
},
{
tableName: "usuarios",
timestamps: true,
}
);

module.exports = { Usuario };
1 change: 0 additions & 1 deletion backend/node_modules/.bin/semver

This file was deleted.

1 change: 0 additions & 1 deletion backend/node_modules/.bin/uuid

This file was deleted.

Loading