diogenes 2 yıl önce
ebeveyn
işleme
cc2d4568de

+ 2 - 2
Atualiza_integrador_saperx.sh

@@ -4,9 +4,9 @@
 echo '------> INICIANDO ATUALIZACAO'
 
 rm integradorsaperx -rf
-git clone https://diogenes:Bd121012@git.tutech.com.br/TU/saperx.git integradorsaperx
+git clone https://diogenes:Bd121012@git.tutech.com.br/alfred/saperx.git integradorsaperx
 cd integradorsaperx
-docker build . -t tu/integradorsaperx --no-cache
+docker build . -t alfred/saperx --no-cache
 cd
 rm integradorsaperx -rf
 echo '-----> FIM'

+ 1 - 1
Dockerfile

@@ -1,4 +1,4 @@
-FROM node:18
+FROM node:20
 
 ENV TZ America/Sao_Paulo
 WORKDIR /var/www/dados/

+ 1 - 11
src/config/db.config.js

@@ -1,15 +1,6 @@
 require('dotenv').config()
 
-const mysql = require('mysql');
-const connection = mysql.createConnection({
-  host: process.env.DB_HOST,
-  port: process.env.DB_PORT,
-  user: process.env.DB_USER,
-  password: process.env.DB_PASS,
-  database: process.env.DB_SCHEMA,
-  charset: "utf8mb4",
-  collation: "utf8mb4_bin",
-});
+
 
 var knex = require('knex')({
   client: 'mysql',
@@ -46,6 +37,5 @@ var knexlocal = require('knex')({
 });
 
 
-module.exports.connection = connection;
 module.exports.knex = knex;
 module.exports.knexlocal = knexlocal;

+ 12 - 5
src/factories/Banco.factory.js

@@ -1,13 +1,20 @@
 const clc = require("cli-color");
 var { version } = require("../../package.json");
-const { connection, knex } = require("../config/db.config");
+const { knex } = require("../config/db.config");
 
 class BancodedadosFactory {
   static Iniciar(client, data) {
-    connection.connect(function (err) {
-      if (err) throw err;
-      console.log(clc.green("BANCO DE DADOS CONECTOU ---> LoL!"));
-    });
+    knex
+      .raw("SELECT 1+1 as result")
+      .then((result) => {
+        console.log(clc.green("BANCO DE DADOS CONECTOU ---> LoL!"));
+      })
+      .catch((error) => {
+        console.error("Erro ao conectar ao banco de dados:", error);
+      })
+      .finally(() => {
+        knex.destroy(); // Feche a conexão
+      });
   }
   static InstallMigrations() {
     return knex.migrate.latest().then(() => {