package main

import (
	"net/http"
	"os"
	"simple-cluster-node/router"

	log "gitlab.com/gdulai/simpleloglvl"

	"github.com/joho/godotenv"
)

func main() {
	// Setup logs
	log.SetupLogs()

	log.LogInfo("Application starting...")

	// Load env file
	err := godotenv.Load()
	if err != nil {
		log.LogFatalError("Failed to load .env file")
	}

	port := os.Getenv("PORT")
	if port == "" {
		port = "8080"
	}

	log.LogInfo("Application started on port %s", port)

	r := router.SetupRouter()
	http.ListenAndServe(":"+port, r)
}
