24 lines
705 B
Go
24 lines
705 B
Go
package auth
|
|
|
|
import (
|
|
"github.com/gofiber/fiber/v2"
|
|
"github.com/techxcar/backend/internal/config"
|
|
redispkg "github.com/techxcar/backend/pkg/redis"
|
|
)
|
|
|
|
func RegisterRoutes(app *fiber.App, repo LoginRepository, rdb *redispkg.Redis, cfg *config.Config) {
|
|
authGroup := app.Group("/api/v1/auth")
|
|
|
|
if rdb != nil {
|
|
storage := NewRedisStorage(rdb.Client)
|
|
rateLimiter := RateLimiter(storage)
|
|
authGroup.Post("/login", rateLimiter, LoginHandler(repo, rdb, cfg))
|
|
authGroup.Post("/refresh", rateLimiter, RefreshHandler(rdb, cfg))
|
|
} else {
|
|
authGroup.Post("/login", LoginHandler(repo, rdb, cfg))
|
|
authGroup.Post("/refresh", RefreshHandler(rdb, cfg))
|
|
}
|
|
|
|
authGroup.Post("/logout", LogoutHandler(rdb))
|
|
}
|