Inicial
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
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))
|
||||
}
|
||||
Reference in New Issue
Block a user