package api

import (
	"github.com/gin-gonic/gin"
	"github.com/jmoiron/sqlx"
)

func SetupServer(db *sqlx.DB) *gin.Engine {
	server := createServer()
	LoadTemplates(server)
	RegisterRoutes(server, db)
	return server
}

func createServer() *gin.Engine {
	server := gin.New()
	server.NoRoute(NoRoute())
	server.NoMethod(NoMethod())
	server.Use(gin.Recovery())
	server.Static("assets", "assets")
	return server
}
