package main

import (
	"api/database"
	"api/routes"
	"log"
	"os"

	"github.com/gofiber/fiber/v2"
	"github.com/gofiber/fiber/v2/middleware/cors"
)

func main() {
	app := fiber.New(fiber.Config{
		StrictRouting:         false,
		DisableStartupMessage: true,
	})

	app.Use(cors.New(cors.Config{
		AllowCredentials: true,
	}))

	app.Static("/", "./frontend")

	if err := database.ConnectDB(); err != nil {
		panic("Could not connect to database")
	}

	routes.Setup(app)

	log.Println("Server started in port " + os.Getenv("API_PORT"))
	app.Listen(":" + os.Getenv("API_PORT"))
}
