import jwt from 'jsonwebtoken';
import type { SignOptions } from 'jsonwebtoken';
import config from '@/shared/config';
import { JWT_EXPIRES_IN } from '@/shared/constants/auth';

/** Signs a short-lived access JWT with the application secret. */
export function jwtSign(data: object): string {
  const options: SignOptions = { expiresIn: JWT_EXPIRES_IN };
  return jwt.sign(data, config.secret_key, options);
}
