Moved handler to use interfaces and added the refreshToken endpoint
This commit is contained in:
parent
0383d554b8
commit
b02ed3f86a
@ -5,7 +5,6 @@ import (
|
||||
"net/http"
|
||||
|
||||
"git.jamestombleson.com/jtom38/go-cook/internal/domain"
|
||||
"git.jamestombleson.com/jtom38/go-cook/internal/repositories"
|
||||
"git.jamestombleson.com/jtom38/go-cook/internal/services"
|
||||
|
||||
"github.com/golang-jwt/jwt/v5"
|
||||
@ -16,19 +15,18 @@ import (
|
||||
type Handler struct {
|
||||
Config domain.EnvConfig
|
||||
|
||||
UserService services.UserService
|
||||
userRepo repositories.IUserTable
|
||||
recipeRepo repositories.IRecipeTable
|
||||
refreshTokenRepo repositories.RefreshTokenRepository
|
||||
users services.UserService
|
||||
recipes services.Recipes
|
||||
refreshTokens services.RefreshToken
|
||||
}
|
||||
|
||||
func NewHandler(conn *sql.DB, cfg domain.EnvConfig) *Handler {
|
||||
return &Handler{
|
||||
Config: cfg,
|
||||
UserService: services.NewUserService(conn),
|
||||
userRepo: repositories.NewUserRepository(conn),
|
||||
recipeRepo: repositories.NewRecipeRepository(conn),
|
||||
refreshTokenRepo: repositories.NewRefreshTokenRepository(conn),
|
||||
Config: cfg,
|
||||
|
||||
users: services.NewUserService(conn),
|
||||
recipes: services.NewRecipesService(conn),
|
||||
refreshTokens: services.NewRefreshTokenService(conn),
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,6 +44,7 @@ func (h *Handler) Register(v1 *echo.Group) {
|
||||
auth.Use(echojwt.WithConfig(jwtConfig))
|
||||
auth.POST("/scopes/add", h.AddScopes)
|
||||
auth.POST("/scopes/remove", h.RemoveScopes)
|
||||
auth.POST("/refreshToken", h.RefreshJwtToken)
|
||||
|
||||
demo := v1.Group("/demo")
|
||||
demo.GET("/hello", h.DemoHello)
|
||||
|
Loading…
Reference in New Issue
Block a user