import { nanoid } from 'nanoid'; import { nanoidDictionary } from 'nanoid-dictionary'; export function generateId(length = 21): string { return nanoid(length); } export function generateVerificationCode(): string { const dictionary = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789'; // Remove confusing chars: I, O, 0, 1 let code = ''; for (let i = 0; i < 6; i++) { code += dictionary[Math.floor(Math.random() * dictionary.length)]; } return code; } export function generateSecureToken(length = 32): string { return nanoid(length); } export function slugify(text: string): string { return text .toLowerCase() .trim() .replace(/[^\w\s-]/g, '') .replace(/[\s_-]+/g, '-') .replace(/^-+|-+$/g, ''); } export function generateChannelSlug(name: string): string { const base = slugify(name); const suffix = nanoid(6).toLowerCase(); return `${base}-${suffix}`; }