From e76d77dadd0e37c31453ada84aa51db599706fa0 Mon Sep 17 00:00:00 2001 From: Ly Tuan Kiet Date: Fri, 18 Oct 2024 15:02:06 +0700 Subject: [PATCH] fix upload --- src/Center/center.schema.ts | 12 +----------- src/Service/service.schema.ts | 12 +----------- src/UploadedFile/uploadedfile.schema.ts | 12 +----------- src/Workshop/workshop.schema.ts | 12 +----------- 4 files changed, 4 insertions(+), 44 deletions(-) diff --git a/src/Center/center.schema.ts b/src/Center/center.schema.ts index 57aa4d6..7c8578e 100644 --- a/src/Center/center.schema.ts +++ b/src/Center/center.schema.ts @@ -43,18 +43,8 @@ export class CenterSchema extends PothosSchema { description: t.exposeString('description', { description: 'The description of the center.', }), - logoUrl: t.string({ + logoUrl: t.exposeString('logoUrl', { description: 'The URL of the center logo.', - resolve: async (center, args, ctx) => { - const fileUrl = await this.minioService.getFileUrl( - center.uploadedFileId ?? '', - 'centers', - ); - if (!fileUrl) { - return ''; - } - return fileUrl; - }, }), logoFile: t.relation('logoFile', { description: 'The file associated with the center logo.', diff --git a/src/Service/service.schema.ts b/src/Service/service.schema.ts index fcfac8e..bca00f6 100644 --- a/src/Service/service.schema.ts +++ b/src/Service/service.schema.ts @@ -50,18 +50,8 @@ export class ServiceSchema extends PothosSchema { imageFileId: t.exposeID('imageFileId', { description: 'The ID of the image file for the service.', }), - imageFileUrl: t.string({ + imageFileUrl: t.exposeString('imageFileUrl', { description: 'The URL of the image file for the service.', - resolve: async (service, args, ctx) => { - const fileUrl = await this.minioService.getFileUrl( - service.imageFileId ?? '', - 'services', - ); - if (!fileUrl) { - return ''; - } - return fileUrl; - }, }), createdAt: t.expose('createdAt', { type: 'DateTime', diff --git a/src/UploadedFile/uploadedfile.schema.ts b/src/UploadedFile/uploadedfile.schema.ts index 71238cd..be157a6 100644 --- a/src/UploadedFile/uploadedfile.schema.ts +++ b/src/UploadedFile/uploadedfile.schema.ts @@ -42,18 +42,8 @@ export class UploadedFileSchema extends PothosSchema { nullable: false, description: 'The type of the file.', }), - fileUrl: t.string({ + fileUrl: t.exposeString('fileUrl', { description: 'The URL of the file.', - resolve: async (file, args, ctx) => { - const fileUrl = await this.minioService.getFileUrl( - file.fileName, - 'files', - ); - if (!fileUrl) { - return ''; - } - return fileUrl; - }, }), uploadedAt: t.expose('uploadedAt', { type: 'DateTime', diff --git a/src/Workshop/workshop.schema.ts b/src/Workshop/workshop.schema.ts index cf25ac9..b97e3c0 100644 --- a/src/Workshop/workshop.schema.ts +++ b/src/Workshop/workshop.schema.ts @@ -46,18 +46,8 @@ export class WorkshopSchema extends PothosSchema { imageFileId: t.exposeID('imageFileId', { description: 'The ID of the image file for the workshop.', }), - imageFileUrl: t.string({ + imageFileUrl: t.exposeString('imageFileUrl', { description: 'The URL of the image file for the workshop.', - resolve: async (workshop, args, ctx) => { - const fileUrl = await this.minioService.getFileUrl( - workshop.imageFileId ?? '', - 'workshops', - ); - if (!fileUrl) { - throw new Error('Cannot retrieve file url'); - } - return fileUrl; - }, }), date: t.expose('date', { type: 'DateTime',