refactor and update get url logic

This commit is contained in:
2024-10-17 17:02:03 +07:00
parent 4721077370
commit f9967ac5bd
22 changed files with 45 additions and 40 deletions

View File

@@ -1,7 +1,6 @@
import { Global, Module } from '@nestjs/common';
import { Module } from '@nestjs/common';
import { ResumeSchema } from './resume.schema';
@Global()
@Module({
providers: [ResumeSchema],
exports: [ResumeSchema],

View File

@@ -53,8 +53,18 @@ export class ResumeSchema extends PothosSchema {
resumeId: t.exposeID('resumeId', {
description: 'The ID of the resume.',
}),
fileUrl: t.exposeString('fileUrl', {
fileUrl: t.string({
description: 'The URL of the resume file.',
resolve: async (file, args, ctx) => {
const fileUrl = await this.minioService.getFileUrl(
file.fileUrl,
'resumes',
);
if (!fileUrl) {
throw new Error('Cannot retrieve file url');
}
return fileUrl;
},
}),
type: t.exposeString('type', {
description: 'The type of the resume file.',