Use crypto to generate ids
This commit is contained in:
parent
33964ca6d1
commit
a17b7595c1
|
@ -1,5 +1,6 @@
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import { ServerSideReview, UserSideReview } from "../types";
|
import { ServerSideReview, UserSideReview } from "../types";
|
||||||
|
import * as crypto from "crypto";
|
||||||
|
|
||||||
export function checkFile(
|
export function checkFile(
|
||||||
file: string,
|
file: string,
|
||||||
|
@ -23,9 +24,7 @@ export function checkFile(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generates a unique 6-character ID
|
// Generates a unique 6-character ID
|
||||||
export function generateId(): string {
|
export const generateId = (): string => crypto.randomBytes(3).toString("hex");
|
||||||
return Math.random().toString(36).replace("0.", "").substring(0, 6);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function appendId(userReview: UserSideReview): ServerSideReview {
|
export function appendId(userReview: UserSideReview): ServerSideReview {
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in a new issue