run eslint

This commit is contained in:
2024-10-15 20:05:54 +07:00
parent c208c27a64
commit 7d7765c70f
15 changed files with 833 additions and 780 deletions

View File

@@ -44,7 +44,7 @@ export class UploadedFileSchema extends PothosSchema {
uploadedFile: t.prismaField({
type: this.uploadedFile(),
args: this.builder.generator.findUniqueArgs('UploadedFile'),
resolve: async (query, root, args, ctx, info) => {
resolve: async (query, root, args) => {
const file = await this.prisma.uploadedFile.findUnique({
...query,
where: args.where,
@@ -66,7 +66,7 @@ export class UploadedFileSchema extends PothosSchema {
uploadedFiles: t.prismaField({
type: [this.uploadedFile()],
args: this.builder.generator.findManyArgs('UploadedFile'),
resolve: async (query, root, args, ctx, info) => {
resolve: async (query, root, args) => {
const files = await this.prisma.uploadedFile.findMany({
...query,
skip: args.skip ?? 0,
@@ -105,7 +105,7 @@ export class UploadedFileSchema extends PothosSchema {
required: true,
}),
},
resolve: async (query, root, args, ctx, info) => {
resolve: async (query, root, args) => {
const user = await this.prisma.user.findUnique({
where: {
id: args.userId,
@@ -114,16 +114,16 @@ export class UploadedFileSchema extends PothosSchema {
if (!user) {
throw new Error('User not found');
}
// convert graphql upload to file
// upload file to minio
const { filename, mimetype } = await this.minioService.uploadFile(
args.file,
'files',
);
// getFileUrl
let fileUrl = await this.minioService.getFileUrl(filename, 'files');
if (!mimetype) {
throw new Error('File type not supported');
}
const fileUrl = await this.minioService.getFileUrl(filename, 'files');
if (!fileUrl) {
fileUrl = '';
throw new Error('Cannot retrieve file url, please try again later');
}
const uploadedFile = await this.prisma.uploadedFile.create({
data: {