package server

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

var (
	defaultCORS = cors.New(cors.Config{
		AllowOrigins:     "*",
		AllowCredentials: true,
		AllowMethods:     "GET, POST, PATCH, PUT, DELETE, OPTIONS",
		AllowHeaders:     "Accept, Authorization, Content-Type, Vary, X-Request-Id",
	})
)

func SetupRouter(s *Server) {
	s.Base.Options("*", defaultCORS)

	s.Base.Get("/health", s.HealthHandler)
	s.Base.Get("/config", s.ConfigHandler)

	api := s.Base.Group("/api")
	v1 := api.Group("/v1")
	v1.Post("/login", s.LoginHandler)
	v1.All("/traefik", s.TraefikHandler)
}
