Refresh Token Support and package refactor based on best practice docs #18

Merged
jtom38 merged 15 commits from features/restructure-go-recommendations into main 2024-04-21 10:30:52 -07:00
Showing only changes of commit b02ed3f86a - Show all commits

View File

@ -5,7 +5,6 @@ import (
"net/http" "net/http"
"git.jamestombleson.com/jtom38/go-cook/internal/domain" "git.jamestombleson.com/jtom38/go-cook/internal/domain"
"git.jamestombleson.com/jtom38/go-cook/internal/repositories"
"git.jamestombleson.com/jtom38/go-cook/internal/services" "git.jamestombleson.com/jtom38/go-cook/internal/services"
"github.com/golang-jwt/jwt/v5" "github.com/golang-jwt/jwt/v5"
@ -16,19 +15,18 @@ import (
type Handler struct { type Handler struct {
Config domain.EnvConfig Config domain.EnvConfig
UserService services.UserService users services.UserService
userRepo repositories.IUserTable recipes services.Recipes
recipeRepo repositories.IRecipeTable refreshTokens services.RefreshToken
refreshTokenRepo repositories.RefreshTokenRepository
} }
func NewHandler(conn *sql.DB, cfg domain.EnvConfig) *Handler { func NewHandler(conn *sql.DB, cfg domain.EnvConfig) *Handler {
return &Handler{ return &Handler{
Config: cfg, Config: cfg,
UserService: services.NewUserService(conn),
userRepo: repositories.NewUserRepository(conn), users: services.NewUserService(conn),
recipeRepo: repositories.NewRecipeRepository(conn), recipes: services.NewRecipesService(conn),
refreshTokenRepo: repositories.NewRefreshTokenRepository(conn), refreshTokens: services.NewRefreshTokenService(conn),
} }
} }
@ -46,6 +44,7 @@ func (h *Handler) Register(v1 *echo.Group) {
auth.Use(echojwt.WithConfig(jwtConfig)) auth.Use(echojwt.WithConfig(jwtConfig))
auth.POST("/scopes/add", h.AddScopes) auth.POST("/scopes/add", h.AddScopes)
auth.POST("/scopes/remove", h.RemoveScopes) auth.POST("/scopes/remove", h.RemoveScopes)
auth.POST("/refreshToken", h.RefreshJwtToken)
demo := v1.Group("/demo") demo := v1.Group("/demo")
demo.GET("/hello", h.DemoHello) demo.GET("/hello", h.DemoHello)