import { customAlphabet } from "nanoid"
export * from "./cors"

const customCyperAlphabet =
  "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

/**
 * Random ID generator
 *
 * @param length - Required length for the output
 * @returns Function that generates random IDs
 * @example
 * const generateId = randomIdGenerator(12);
 * const id = generateId(); // => 'gdh6326GDJh0'
 */
const randomIdGenerator = (length = 16): (() => string) =>
  customAlphabet(customCyperAlphabet, length)

export { randomIdGenerator }
