forked from Shared/esg
initial commit
This commit is contained in:
11
src/common/helpers/tracking-code.helper.ts
Normal file
11
src/common/helpers/tracking-code.helper.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { randomBytes } from 'crypto';
|
||||
import { TRACKING_CODE_PREFIX } from '../constants/app.constants';
|
||||
|
||||
/**
|
||||
* Generates a unique, human-readable tracking code per inquiry.
|
||||
*/
|
||||
export function generateTrackingCode(): string {
|
||||
const date = new Date().toISOString().slice(0, 10).replace(/-/g, '');
|
||||
const suffix = randomBytes(4).toString('hex').toUpperCase();
|
||||
return `${TRACKING_CODE_PREFIX}-${date}-${suffix}`;
|
||||
}
|
||||
Reference in New Issue
Block a user