refactor: more consistent naming for object handler

This commit is contained in:
DecDuck
2024-11-16 16:11:20 +11:00
parent 4488ae269b
commit 87230fb0e7
2 changed files with 4 additions and 4 deletions

View File

@ -4,7 +4,7 @@ This is used as a utility in metadata handling, so we only fetch the objects if
*/ */
import { Readable } from "stream"; import { Readable } from "stream";
import { v4 as uuidv4 } from "uuid"; import { v4 as uuidv4 } from "uuid";
import { GlobalObjectHandler } from "~/server/plugins/objects"; import { objectHandler } from "~/server/plugins/objects";
type TransactionDataType = string | Readable | Buffer; type TransactionDataType = string | Readable | Buffer;
type TransactionTable = { [key: string]: TransactionDataType }; // ID to data type TransactionTable = { [key: string]: TransactionDataType }; // ID to data
@ -34,7 +34,7 @@ export class ObjectTransactionalHandler {
const pull = async () => { const pull = async () => {
for (const [id, data] of Object.entries(this.record[transactionId])) { for (const [id, data] of Object.entries(this.record[transactionId])) {
await GlobalObjectHandler.createFromSource( await objectHandler.createFromSource(
id, id,
() => { () => {
if (typeof data === "string") { if (typeof data === "string") {

View File

@ -1,10 +1,10 @@
import { FsObjectBackend } from "../internal/objects/fsBackend"; import { FsObjectBackend } from "../internal/objects/fsBackend";
// To-do insert logic surrounding deciding what object backend to use // To-do insert logic surrounding deciding what object backend to use
export const GlobalObjectHandler = new FsObjectBackend(); export const objectHandler = new FsObjectBackend();
export default defineNitroPlugin((nitro) => { export default defineNitroPlugin((nitro) => {
nitro.hooks.hook("request", (h3) => { nitro.hooks.hook("request", (h3) => {
h3.context.objects = GlobalObjectHandler; h3.context.objects = objectHandler;
}); });
}); });