Skip to content

Commit

Permalink
alteração de modo de conexão do banco
Browse files Browse the repository at this point in the history
  • Loading branch information
yaskisoba committed Dec 6, 2023
1 parent 03cdabd commit 2ecca3f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 39 deletions.
11 changes: 11 additions & 0 deletions backend/config/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require("dotenv").config();

const config = {
username: process.env.DB_USERNAME || "root",
password: process.env.DB_PASSWORD || null,
database: process.env.DB_DATABASE || "database",
host: process.env.DB_HOST || "127.0.0.1",
dialect: "mysql",
};

module.exports = config;
23 changes: 0 additions & 23 deletions backend/config/config.json

This file was deleted.

9 changes: 1 addition & 8 deletions backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,7 @@ app.use('/elective', electiveRoute);
app.use('/learningpath', learningPathRoute);
app.use('/api', logoutRoutes);

// sequelize
// .sync()
// .then(() => {
// console.log('Conexão bem-sucedida com o banco de dados');
// })
// .catch((error) => {
// console.error('Erro ao conectar-se ao banco de dados:', error);
// });
let test = process.env.DB_USERNAME


database.sequelize.sync().then(() => {
Expand Down
10 changes: 2 additions & 8 deletions backend/models/schemas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,10 @@ const path = require('path');
const Sequelize = require('sequelize');
const process = require('process');
const basename = path.basename(__filename);
const env = process.env.NODE_ENV || 'development';
const config = require(__dirname + '/../../config/config.json')[env];
const config = require(__dirname + '/../../config/config.js');
const db = {};

let sequelize;
if (config.use_env_variable) {
sequelize = new Sequelize(process.env[config.use_env_variable], config);
} else {
sequelize = new Sequelize(config.database, config.username, config.password, config);
}
let sequelize = new Sequelize(config.database, config.username, config.password, config);

fs
.readdirSync(__dirname)
Expand Down
16 changes: 16 additions & 0 deletions backend/versel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"version": 2,
"builds": [
{
"src": "index.js",
"use": "@vercel/node"
}

],
"routes": [
{
"src": "(.*)",
"dest": "index.js"
}
]
}

0 comments on commit 2ecca3f

Please sign in to comment.