package main

import (
	"log"

	"git.kocoder.xyz/kocoded/szuntis-backend/auth"
	"git.kocoder.xyz/kocoded/szuntis-backend/middleware"
	"git.kocoder.xyz/kocoded/szuntis-backend/router"
	"github.com/gofiber/fiber/v2"
)

func main() {
	// dsn := "postgresql://app1:p5ohxMubZHhzsvSQevlFfw@cockroach-db-1-11072.7tc.aws-eu-central-1.cockroachlabs.cloud:26257/defaultdb?sslmode=verify-full"
	// db, err := gorm.Open(postgres.Open(dsn), &gorm.Config{})
	// if err != nil {
	// 	log.Fatal("failed to connect database", err)
	// }

	ar := auth.NewMemeoryAuthRepository()
	app := fiber.New()

	api := app.Group("/api")
	router.NewAuthRouter(ar, middleware.NewAuthMiddleware(ar), api.Group("auth"))
	router.NewWebSocketRouter(middleware.NewWsMiddleware(), api.Group("web"))
	api.Use(middleware.NewWsMiddleware().IsWebscoketUpgrade)

	log.Fatal(app.Listen(":3000"))
}
