// Packages
import express from "express";
import cors from "cors";

// Connections
import { mongoConnection, redisConnection } from "$connections/index.js";

// Configs
import { appConfig, databaseConfig } from "$config/index.js";

// Router
import router from "$routes/index.js";
import { startCronJobs } from "$jobs/cron.js";
import { startTelegramBot } from "$root/bot/index.js";
import { assertTelegramBotConfiguration } from "$root/bot/config.js";

const { mongoConfig, redisConfig } = databaseConfig;
const app = express();

app.use(express.json({ limit: "50mb" }));
app.use(cors());
app.use("/v1", router);



app.listen(appConfig.port, async () => {
  console.log("✅ APP IS RUNNING", appConfig);
  startCronJobs();


  mongoConnection.on("connected", async () => {
    console.log("✅ DATABASE CONNECTED", mongoConfig);
  });

  redisConnection.on("connect", () => {
    console.log("✅ REDIS CONNECTED", redisConfig);
  });
});
