41 lines
1.0 KiB
Go
41 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"time"
|
|
"zardzul/music-index/database"
|
|
_ "zardzul/music-index/docs"
|
|
"zardzul/music-index/handlers"
|
|
"zardzul/music-index/repository"
|
|
"zardzul/music-index/routes"
|
|
"zardzul/music-index/utils"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// @title Music Index API
|
|
// @version 1.0
|
|
// @description API for managing users and artists in Music Index.
|
|
// @BasePath /api/v1/
|
|
|
|
func main() {
|
|
|
|
config := utils.LoadConfig()
|
|
pool, queries, databaseError := database.Connect(config.DBURL)
|
|
if databaseError != nil {
|
|
panic(databaseError)
|
|
}
|
|
defer pool.Close()
|
|
|
|
userRepo := repository.NewUserRepository(queries)
|
|
userHandler := handlers.NewUserHandler(userRepo, config.JWTsecret, config.JWTIssuer, time.Duration(config.JWTTTL)*time.Minute)
|
|
artistRepo := repository.NewArtistRepository(queries)
|
|
artistHandler := handlers.NewArtistHandler(artistRepo)
|
|
|
|
router := gin.Default()
|
|
routes.Routes(router, userHandler, artistHandler, config.JWTsecret)
|
|
|
|
if routerError := router.Run(":8080"); routerError != nil {
|
|
panic(routerError)
|
|
}
|
|
}
|