package handlers

import (
	"time"

	"hyperia/config"
	"github.com/golang-jwt/jwt/v5"
)

func GenerateJWT(userId int) (string, error) {
	claims := jwt.MapClaims{
		"applicant_id": userId,
		"exp":          time.Now().Add(2 * time.Hour).Unix(), // expires in 2 hours
		"iat":          time.Now().Unix(),
	}

	token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
	jwtSecret := []byte(config.JWT_SECRET)
	signedToken, err := token.SignedString(jwtSecret)
	if err != nil {
		return "", err
	}
	return signedToken, nil
}