Files
zerobyte/app/server/utils/id.ts
Nico ae5233d9fb refactor: tag snapshots with schedule short_id instead of db id (#248)
* refactor: tag snapshots with schedule short_id instead of db id

* chore: formatting issues
2025-12-28 11:42:25 +01:00

7 lines
225 B
TypeScript

import crypto from "node:crypto";
export const generateShortId = (length = 8): string => {
const bytesNeeded = Math.ceil((length * 3) / 4);
return crypto.randomBytes(bytesNeeded).toString("base64url").slice(0, length);
};