From b02ed3f86a4e2a809ca788c79e3f462a80a95364 Mon Sep 17 00:00:00 2001 From: James Tombleson Date: Sun, 21 Apr 2024 08:59:51 -0700 Subject: [PATCH] Moved handler to use interfaces and added the refreshToken endpoint --- internal/handlers/v1/handler.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/internal/handlers/v1/handler.go b/internal/handlers/v1/handler.go index d40e92a..567b7ce 100644 --- a/internal/handlers/v1/handler.go +++ b/internal/handlers/v1/handler.go @@ -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)