import jwt from "jsonwebtoken";

const SECRET_KEY: jwt.Secret = process.env.JWT_SECRET || "supersecretkey";

export class JwtHelper {
  static generateToken(payload: object, expiresIn = "1h"): string {
    const params: jwt.SignOptions = { expiresIn: expiresIn as jwt.SignOptions["expiresIn"] };
    return jwt.sign(payload, SECRET_KEY, params);
  }

  static verifyToken(token: string): any {
    return jwt.verify(token, SECRET_KEY);
  }
}
