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"
"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)