Actualizar server.js
This commit is contained in:
29
server.js
29
server.js
@@ -32,19 +32,25 @@ app.use(express.json({ limit: '10mb' }));
|
|||||||
app.use(express.urlencoded({ limit: '10mb', extended: true }));
|
app.use(express.urlencoded({ limit: '10mb', extended: true }));
|
||||||
|
|
||||||
// VARIABLES DE ENTORNO
|
// VARIABLES DE ENTORNO
|
||||||
|
// --- 1. VARIABLES DE ENTORNO ---
|
||||||
const {
|
const {
|
||||||
DATABASE_URL,
|
DATABASE_URL,
|
||||||
JWT_SECRET,
|
JWT_SECRET,
|
||||||
EVOLUTION_BASE_URL,
|
EVOLUTION_BASE_URL,
|
||||||
EVOLUTION_API_KEY,
|
EVOLUTION_API_KEY,
|
||||||
EVOLUTION_INSTANCE,
|
EVOLUTION_INSTANCE,
|
||||||
OPENAI_API_KEY, // 🔔 AÑADIDO
|
OPENAI_API_KEY, // 🔔 LEER LLAVE
|
||||||
OPENAI_MODEL // 🔔 AÑADIDO
|
OPENAI_MODEL // 🔔 LEER MODELO
|
||||||
} = process.env;
|
} = process.env;
|
||||||
|
|
||||||
// --- DIAGNÓSTICO DE INICIO ---
|
// --- 2. INICIALIZACIÓN GLOBAL DEL MOTOR IA (ESTO ES LO QUE TE FALTABA) ---
|
||||||
|
const openai = new OpenAI({
|
||||||
|
apiKey: OPENAI_API_KEY,
|
||||||
|
});
|
||||||
|
|
||||||
|
// --- 3. DIAGNÓSTICO DE INICIO ---
|
||||||
console.log("------------------------------------------------");
|
console.log("------------------------------------------------");
|
||||||
console.log("🚀 VERSIÓN COMPLETA - CON AUTOMATISMOS REALES");
|
console.log("🚀 VERSIÓN COMPLETA - INTEGRA REPARA SAAS");
|
||||||
console.log("------------------------------------------------");
|
console.log("------------------------------------------------");
|
||||||
|
|
||||||
if (!OPENAI_API_KEY) {
|
if (!OPENAI_API_KEY) {
|
||||||
@@ -61,21 +67,6 @@ else console.log("✅ Instancia Notificaciones:", EVOLUTION_INSTANCE);
|
|||||||
|
|
||||||
console.log("------------------------------------------------");
|
console.log("------------------------------------------------");
|
||||||
|
|
||||||
// --- DIAGNÓSTICO DE INICIO ---
|
|
||||||
console.log("------------------------------------------------");
|
|
||||||
console.log("🚀 VERSIÓN COMPLETA - CON AUTOMATISMOS REALES");
|
|
||||||
console.log("------------------------------------------------");
|
|
||||||
if (!DATABASE_URL) console.error("❌ FALTA: DATABASE_URL");
|
|
||||||
if (!JWT_SECRET) console.error("❌ FALTA: JWT_SECRET");
|
|
||||||
|
|
||||||
if (!EVOLUTION_BASE_URL) console.error("⚠️ AVISO: Falta EVOLUTION_BASE_URL");
|
|
||||||
else console.log("✅ Evolution URL:", EVOLUTION_BASE_URL);
|
|
||||||
|
|
||||||
if (!EVOLUTION_INSTANCE) console.error("⚠️ AVISO: Falta EVOLUTION_INSTANCE");
|
|
||||||
else console.log("✅ Instancia Notificaciones:", EVOLUTION_INSTANCE);
|
|
||||||
|
|
||||||
console.log("------------------------------------------------");
|
|
||||||
|
|
||||||
if (!DATABASE_URL || !JWT_SECRET) process.exit(1);
|
if (!DATABASE_URL || !JWT_SECRET) process.exit(1);
|
||||||
|
|
||||||
const pool = new Pool({ connectionString: DATABASE_URL, ssl: false });
|
const pool = new Pool({ connectionString: DATABASE_URL, ssl: false });
|
||||||
|
|||||||
Reference in New Issue
Block a user