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 { CategorySchema } from './category.schema';
@Global()
@Module({
providers: [CategorySchema],
exports: [CategorySchema],

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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.',

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -39,7 +39,19 @@ export class UploadedFileSchema extends PothosSchema {
nullable: false,
description: 'The type of the file.',
}),
fileUrl: t.exposeString('fileUrl'),
fileUrl: t.string({
description: 'The URL of the file.',
resolve: async (file, args, ctx) => {
const fileUrl = await this.minioService.getFileUrl(
file.fileName,
'files',
);
if (!fileUrl) {
throw new Error('Cannot retrieve file url');
}
return fileUrl;
},
}),
uploadedAt: t.expose('uploadedAt', {
type: 'DateTime',
nullable: true,

View File

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

View File

@@ -1,4 +1,4 @@
import { Inject, Injectable } from '@nestjs/common';
import { Inject, Injectable, Logger } from '@nestjs/common';
import {
Pothos,
PothosRef,
@@ -99,7 +99,7 @@ export class UserSchema extends PothosSchema {
resolve: async (query, root, args, ctx, info) => {
// check if the token is valid
const session = await clerkClient.sessions.getSession(args.sessionId);
console.log(session);
Logger.log(session, 'Session');
return await this.prisma.user.findFirst({
...query,
where: {

View File

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

View File

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

View File

@@ -9,8 +9,8 @@ import { RestfulModule } from './Restful/restful.module';
ConfigModule.forRoot({
isGlobal: true,
}),
GraphqlModule,
ClerkModule,
GraphqlModule,
RestfulModule,
],
})