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

43 lines
976 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"
"github.com/joho/godotenv"
)
// @title Music Index API
// @version 1.0
// @description API for managing users and artists in Music Index.
// @BasePath /api/v1/
func main() {
err := godotenv.Load(".env")
if err != nil {
panic("Error loading .env file")
}
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)
}
}