Initial commit
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
! /services/idGenerator.js
|
||||
= Central Unique ID-Generator
|
||||
? This module will create unique ids using crypto
|
||||
*/
|
||||
|
||||
// % import nodejs dependencies
|
||||
import crypto from 'crypto';
|
||||
|
||||
// $ create a new unique id
|
||||
export function generate() { return crypto.randomBytes(32).toString('hex'); } // simple id generator
|
||||
export function generatePrefixed(prefix) { return `${prefix}_${generate()}`; } // prefixed id generator
|
||||
Reference in New Issue
Block a user