Files
music-index/api/main.go
T
2026-03-13 21:03:01 +01:00

37 lines
855 B
Go

package main
import (
"zardzul/music-index/database"
_ "zardzul/music-index/docs"
"zardzul/music-index/handlers"
"zardzul/music-index/repository"
"zardzul/music-index/routes"
"github.com/gin-gonic/gin"
)
// @title Music Index API
// @version 1.0
// @description API for managing users and artists in Music Index.
// @BasePath /
func main() {
pool, queries, databaseError := database.Connect()
if databaseError != nil {
panic(databaseError)
}
defer pool.Close()
userRepo := repository.NewUserRepository(queries)
userHandler := handlers.NewUserHandler(userRepo)
artistRepo := repository.NewArtistRepository(queries)
artistHandler := handlers.NewArtistHandler(artistRepo)
router := gin.Default()
routes.Routes(router, userHandler, artistHandler)
if routerError := router.Run(":8080"); routerError != nil {
panic(routerError)
}
}