refactor: use node crypto uuid

This commit is contained in:
Huskydog9988
2025-04-06 14:08:36 -04:00
parent b4ab6c38fe
commit a01a94fff2
8 changed files with 12 additions and 28 deletions
@@ -11,7 +11,6 @@ import sanitize from "sanitize-filename";
import fs from "fs";
import path from "path";
import { Readable, Stream } from "stream";
import { v4 as uuidv4 } from "uuid";
export class FsObjectBackend extends ObjectBackend {
private baseObjectPath: string;
@@ -17,7 +17,6 @@
import { parse as getMimeTypeBuffer } from "file-type-mime";
import Stream, { Readable, Writable } from "stream";
import { getMimeType as getMimeTypeStream } from "stream-mime-type";
import { v4 as uuidv4 } from "uuid";
export type ObjectReference = string;
export type ObjectMetadata = {
@@ -3,7 +3,7 @@ The purpose of this class is to hold references to remote objects (like images)
This is used as a utility in metadata handling, so we only fetch the objects if we're actually creating a database record.
*/
import { Readable } from "stream";
import { v4 as uuidv4 } from "uuid";
import { randomUUID } from "node:crypto";
import objectHandler from ".";
export type TransactionDataType = string | Readable | Buffer;
@@ -21,12 +21,12 @@ export class ObjectTransactionalHandler {
metadata: { [key: string]: string },
permissions: Array<string>
): [Register, Pull, Dump] {
const transactionId = uuidv4();
const transactionId = randomUUID();
this.record[transactionId] ??= {};
const register = (data: TransactionDataType) => {
const objectId = uuidv4();
const objectId = randomUUID();
this.record[transactionId][objectId] = data;
return objectId;