first commit
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import dotenv from "dotenv";
|
||||
import logger, { logDone, logError, logIntent } from "./config/logger.js";
|
||||
import mongoose from "mongoose";
|
||||
import { Notifications } from "./Models/Notifications/Notifications.js";
|
||||
|
||||
logIntent("Iniciando Notification Sender.");
|
||||
|
||||
logIntent("Cargando variables de entorno.");
|
||||
const envResult = dotenv.config();
|
||||
|
||||
if (envResult.error) {
|
||||
logError("Error cargando variables de entorno:", envResult.error);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
logDone("Variables de entorno cargadas correctamente.");
|
||||
|
||||
const MONGO_URI = process.env.DATABASE_CONNECTION;
|
||||
|
||||
if (!MONGO_URI) {
|
||||
logError("DATABASE_CONNECTION no está definido en las variables de entorno.", "");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
logIntent("Conectando a MongoDB.");
|
||||
mongoose
|
||||
.connect(MONGO_URI)
|
||||
.then(() => {
|
||||
const start = async () => {
|
||||
logDone("Conexión a MongoDB establecida correctamente.");
|
||||
logger.info("🚀 Notification Sender running");
|
||||
|
||||
const worker = new Notifications();
|
||||
await worker.start();
|
||||
};
|
||||
|
||||
start();
|
||||
})
|
||||
.catch((err) => {
|
||||
logError("Error conectando a MongoDB:", err);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user