package middleware

import (
	"net/http"

	memberDomain "apps/backend/internal/module/member/domain"
	tokenDomain "apps/backend/internal/module/token/domain"
)

// AuthJWTMiddleware is goctl middleware name AuthJWT.
type AuthJWTMiddleware struct {
	issuer tokenDomain.Issuer
	store  memberDomain.Repository
}

func NewAuthJWTMiddleware(issuer tokenDomain.Issuer, store memberDomain.Repository) *AuthJWTMiddleware {
	return &AuthJWTMiddleware{issuer: issuer, store: store}
}

func (m *AuthJWTMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc {
	return AuthMiddleware(m.issuer, m.store)(next)
}
