package main

import (
	"eslogad-be/config"
	"eslogad-be/internal/app"
	"eslogad-be/internal/db"
	"eslogad-be/internal/logger"
	"log"
)

func main() {
	cfg := config.LoadConfig()
	logger.Setup(cfg.LogLevel(), cfg.LogFormat())

	db, err := db.NewPostgres(cfg.Database)
	if err != nil {
		log.Fatal(err)
	}

	application := app.NewApp(db)

	if err := application.Initialize(cfg); err != nil {
		log.Fatalf("Failed to initialize application: %v", err)
	}

	if err := application.Start(cfg.Port()); err != nil {
		log.Fatalf("Failed to start server: %v", err)
	}
}
