Skip to content

Commit

Permalink
upload connection vercel
Browse files Browse the repository at this point in the history
  • Loading branch information
coxmau77 committed Jul 8, 2024
1 parent 31bf7c6 commit 81aef0c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
11 changes: 4 additions & 7 deletions controller/user.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,14 @@ const createUser = (request, response) => {
// return response.status(400).json({ message: 'Todos los campos son requeridos.' });
// }

// // Convertir el campo 'favorite' a JSON
// const favoriteJSON = JSON.stringify(favorite);

const SQL = 'INSERT INTO users (nombre, apellido, mail) VALUES (?,?,?)';

dataBase.query(SQL, [nombre, apellido, mail], (error, result) => {

if (error) throw error;
// if (error) {
// return response.status(500).json({ message: 'Error al crear el usuario', error });
// }
// if (error) throw error;
if (error) {
return response.status(500).json({ message: 'Error al crear el usuario', error });
}

response.json({
message: "Usuario creado con éxito",
Expand Down
26 changes: 13 additions & 13 deletions db/bd.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ require('dotenv').config();
const mySQL = require('mysql2');

// Conexion local
// const connection = mySQL.createConnection({
// host: "localhost",
// user: "root",
// password: "admin123",
// database: "online_shop",
// port: 3303
// });
// Conexion para deploy
const connection = mySQL.createConnection({
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
port: process.env.DB_HOST
host: "localhost",
user: "root",
password: "admin123",
database: "online_shop",
port: 3303
});
// // Conexion para deploy
// const connection = mySQL.createConnection({
// host: process.env.DB_HOST,
// user: process.env.DB_USER,
// password: process.env.DB_PASSWORD,
// database: process.env.DB_NAME,
// port: process.env.DB_HOST
// });

connection.connect(error => {
if (error) {
Expand Down

0 comments on commit 81aef0c

Please sign in to comment.