refactor and update get url logic
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
"name": "epess-web-backend",
|
||||
"version": "0.0.1",
|
||||
"description": "",
|
||||
"author": "",
|
||||
"author": "@tuankiet2s",
|
||||
"private": true,
|
||||
"license": "UNLICENSED",
|
||||
"scripts": {
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -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.',
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -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: {
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -9,8 +9,8 @@ import { RestfulModule } from './Restful/restful.module';
|
||||
ConfigModule.forRoot({
|
||||
isGlobal: true,
|
||||
}),
|
||||
GraphqlModule,
|
||||
ClerkModule,
|
||||
GraphqlModule,
|
||||
RestfulModule,
|
||||
],
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user