import QRCode from 'qrcode'; import type { ErrorCorrectionLevel } from '@/types/qrcode'; export async function generateSvg( text: string, errorCorrection: ErrorCorrectionLevel, foregroundColor: string, backgroundColor: string, margin: number, ): Promise { return QRCode.toString(text, { type: 'svg', errorCorrectionLevel: errorCorrection, color: { dark: foregroundColor, light: backgroundColor, }, margin, }); } export async function generateDataUrl( text: string, errorCorrection: ErrorCorrectionLevel, foregroundColor: string, backgroundColor: string, margin: number, size: number, ): Promise { return QRCode.toDataURL(text, { errorCorrectionLevel: errorCorrection, color: { dark: foregroundColor, light: backgroundColor, }, margin, width: size, }); }