package main

import (
	"apskel-pos-be/config"
	"apskel-pos-be/internal/app"
	"apskel-pos-be/internal/db"
	"apskel-pos-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)
	}

	logger.NonContext.Info("helloworld")
	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)
	}
}
