mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
* refactor: use short ids to allow changing the name of volumes & repos * refactor: address PR feedbacks * fix: make short_id non null after initial population
7 lines
225 B
TypeScript
7 lines
225 B
TypeScript
import crypto from "node:crypto";
|
|
|
|
export const generateShortId = (length = 5): string => {
|
|
const bytesNeeded = Math.ceil((length * 3) / 4);
|
|
return crypto.randomBytes(bytesNeeded).toString("base64url").slice(0, length);
|
|
};
|