import { createApp } from "./app.js";
import { connectDatabase } from "./db/mongoose.js";
import config from "./config/index.js";
import logger from "./utils/logger.js";

async function start() {
  try {
    await connectDatabase();
    const app = createApp();
    app.listen(config.port, () => {
      logger.info(`Server is running on http://localhost:${config.port}`);
      logger.info(`Environment: ${config.nodeEnv}`);
      logger.info(`API prefix: ${config.api.prefix}`);
    });
  } catch (error) {
    logger.error("Failed to start server:", error);
    process.exit(1);
  }
}

start();


