run eslint
This commit is contained in:
26
.eslintrc.js
26
.eslintrc.js
@@ -1,26 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
parser: '@typescript-eslint/parser',
|
|
||||||
parserOptions: {
|
|
||||||
project: 'tsconfig.json',
|
|
||||||
tsconfigRootDir: __dirname,
|
|
||||||
sourceType: 'module',
|
|
||||||
},
|
|
||||||
plugins: ['@typescript-eslint/eslint-plugin'],
|
|
||||||
extends: [
|
|
||||||
'plugin:@typescript-eslint/recommended',
|
|
||||||
'plugin:prettier/recommended',
|
|
||||||
],
|
|
||||||
root: true,
|
|
||||||
env: {
|
|
||||||
node: true,
|
|
||||||
jest: true,
|
|
||||||
browser: true,
|
|
||||||
},
|
|
||||||
ignorePatterns: ['.eslintrc.js'],
|
|
||||||
rules: {
|
|
||||||
'@typescript-eslint/interface-name-prefix': 'off',
|
|
||||||
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
||||||
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
||||||
'@typescript-eslint/no-explicit-any': 'off',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
31
package-lock.json
generated
31
package-lock.json
generated
@@ -62,6 +62,7 @@
|
|||||||
"@nestjs/cli": "^10.0.0",
|
"@nestjs/cli": "^10.0.0",
|
||||||
"@nestjs/schematics": "^10.0.0",
|
"@nestjs/schematics": "^10.0.0",
|
||||||
"@nestjs/testing": "^10.0.0",
|
"@nestjs/testing": "^10.0.0",
|
||||||
|
"@stylistic/eslint-plugin-js": "^2.9.0",
|
||||||
"@types/bcryptjs": "^2.4.6",
|
"@types/bcryptjs": "^2.4.6",
|
||||||
"@types/express": "^4.17.17",
|
"@types/express": "^4.17.17",
|
||||||
"@types/jest": "^29.5.2",
|
"@types/jest": "^29.5.2",
|
||||||
@@ -5083,6 +5084,36 @@
|
|||||||
"rxjs": "*"
|
"rxjs": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@stylistic/eslint-plugin-js": {
|
||||||
|
"version": "2.9.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-js/-/eslint-plugin-js-2.9.0.tgz",
|
||||||
|
"integrity": "sha512-h08DQybPsXxIvHIvQqU1tFWcu74M7kZK/0S0jVIDdoHSFq7jB+TzxikBWAg5j0lPR17WsGGGHAS8GHFlAAQXHA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"eslint-visitor-keys": "^4.1.0",
|
||||||
|
"espree": "^10.2.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"eslint": ">=8.40.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@stylistic/eslint-plugin-js/node_modules/eslint-visitor-keys": {
|
||||||
|
"version": "4.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.1.0.tgz",
|
||||||
|
"integrity": "sha512-Q7lok0mqMUSf5a/AdAZkA5a/gHcO6snwQClVNNvFKCAVlxXucdU8pKydU5ZVZjBx5xr37vGbFFWtLQYreLzrZg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"engines": {
|
||||||
|
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://opencollective.com/eslint"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@tsconfig/node10": {
|
"node_modules/@tsconfig/node10": {
|
||||||
"version": "1.0.11",
|
"version": "1.0.11",
|
||||||
"resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz",
|
"resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz",
|
||||||
|
|||||||
@@ -78,6 +78,7 @@
|
|||||||
"@nestjs/cli": "^10.0.0",
|
"@nestjs/cli": "^10.0.0",
|
||||||
"@nestjs/schematics": "^10.0.0",
|
"@nestjs/schematics": "^10.0.0",
|
||||||
"@nestjs/testing": "^10.0.0",
|
"@nestjs/testing": "^10.0.0",
|
||||||
|
"@stylistic/eslint-plugin-js": "^2.9.0",
|
||||||
"@types/bcryptjs": "^2.4.6",
|
"@types/bcryptjs": "^2.4.6",
|
||||||
"@types/express": "^4.17.17",
|
"@types/express": "^4.17.17",
|
||||||
"@types/jest": "^29.5.2",
|
"@types/jest": "^29.5.2",
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ export class CategorySchema extends PothosSchema {
|
|||||||
categories: t.prismaField({
|
categories: t.prismaField({
|
||||||
type: [this.category()],
|
type: [this.category()],
|
||||||
args: this.builder.generator.findManyArgs('Category'),
|
args: this.builder.generator.findManyArgs('Category'),
|
||||||
resolve: async (query, root, args, ctx, info) => {
|
resolve: async (query, root, args) => {
|
||||||
return await this.prisma.category.findMany({
|
return await this.prisma.category.findMany({
|
||||||
...query,
|
...query,
|
||||||
skip: args.skip ?? undefined,
|
skip: args.skip ?? undefined,
|
||||||
@@ -60,7 +60,7 @@ export class CategorySchema extends PothosSchema {
|
|||||||
category: t.prismaField({
|
category: t.prismaField({
|
||||||
type: this.category(),
|
type: this.category(),
|
||||||
args: this.builder.generator.findUniqueArgs('Category'),
|
args: this.builder.generator.findUniqueArgs('Category'),
|
||||||
resolve: async (query, root, args, ctx, info) => {
|
resolve: async (query, root, args) => {
|
||||||
return await this.prisma.category.findUnique({
|
return await this.prisma.category.findUnique({
|
||||||
...query,
|
...query,
|
||||||
where: args.where ?? undefined,
|
where: args.where ?? undefined,
|
||||||
@@ -70,7 +70,7 @@ export class CategorySchema extends PothosSchema {
|
|||||||
subCategories: t.prismaField({
|
subCategories: t.prismaField({
|
||||||
type: [this.subCategory()],
|
type: [this.subCategory()],
|
||||||
args: this.builder.generator.findManyArgs('SubCategory'),
|
args: this.builder.generator.findManyArgs('SubCategory'),
|
||||||
resolve: async (query, root, args, ctx, info) => {
|
resolve: async (query, root, args) => {
|
||||||
return await this.prisma.subCategory.findMany({
|
return await this.prisma.subCategory.findMany({
|
||||||
...query,
|
...query,
|
||||||
where: args.filter ?? undefined,
|
where: args.filter ?? undefined,
|
||||||
@@ -92,7 +92,7 @@ export class CategorySchema extends PothosSchema {
|
|||||||
required: true,
|
required: true,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
resolve: async (query, root, args, ctx, info) => {
|
resolve: async (query, root, args) => {
|
||||||
return await this.prisma.category.create({
|
return await this.prisma.category.create({
|
||||||
data: args.input,
|
data: args.input,
|
||||||
});
|
});
|
||||||
@@ -106,7 +106,7 @@ export class CategorySchema extends PothosSchema {
|
|||||||
required: true,
|
required: true,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
resolve: async (query, root, args, ctx, info) => {
|
resolve: async (query, root, args) => {
|
||||||
return await this.prisma.category.createManyAndReturn({
|
return await this.prisma.category.createManyAndReturn({
|
||||||
data: args.data,
|
data: args.data,
|
||||||
skipDuplicates: true,
|
skipDuplicates: true,
|
||||||
@@ -122,7 +122,7 @@ export class CategorySchema extends PothosSchema {
|
|||||||
required: true,
|
required: true,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
resolve: async (query, root, args, ctx, info) => {
|
resolve: async (query, root, args) => {
|
||||||
return await this.prisma.subCategory.create({
|
return await this.prisma.subCategory.create({
|
||||||
data: args.input,
|
data: args.input,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export class CenterStaffSchema extends PothosSchema {
|
|||||||
centerStaff: t.prismaField({
|
centerStaff: t.prismaField({
|
||||||
type: [this.centerStaff()],
|
type: [this.centerStaff()],
|
||||||
args: this.builder.generator.findManyArgs('CenterStaff'),
|
args: this.builder.generator.findManyArgs('CenterStaff'),
|
||||||
resolve: async (query, root, args, ctx, info) => {
|
resolve: async (query, root, args) => {
|
||||||
return await this.prisma.centerStaff.findMany({
|
return await this.prisma.centerStaff.findMany({
|
||||||
...query,
|
...query,
|
||||||
skip: args.skip ?? undefined,
|
skip: args.skip ?? undefined,
|
||||||
@@ -60,7 +60,7 @@ export class CenterStaffSchema extends PothosSchema {
|
|||||||
required: true,
|
required: true,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
resolve: async (query, root, args, ctx, info) => {
|
resolve: async (query, root, args) => {
|
||||||
return await this.prisma.centerStaff.create({
|
return await this.prisma.centerStaff.create({
|
||||||
...query,
|
...query,
|
||||||
data: args.data,
|
data: args.data,
|
||||||
@@ -80,7 +80,7 @@ export class CenterStaffSchema extends PothosSchema {
|
|||||||
required: true,
|
required: true,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
resolve: async (query, root, args, ctx, info) => {
|
resolve: async (query, root, args) => {
|
||||||
return await this.prisma.centerStaff.update({
|
return await this.prisma.centerStaff.update({
|
||||||
...query,
|
...query,
|
||||||
where: args.where,
|
where: args.where,
|
||||||
@@ -97,7 +97,7 @@ export class CenterStaffSchema extends PothosSchema {
|
|||||||
required: true,
|
required: true,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
resolve: async (query, root, args, ctx, info) => {
|
resolve: async (query, root, args) => {
|
||||||
return await this.prisma.centerStaff.delete({
|
return await this.prisma.centerStaff.delete({
|
||||||
...query,
|
...query,
|
||||||
where: args.where,
|
where: args.where,
|
||||||
|
|||||||
@@ -78,7 +78,10 @@ export class PrismaCrudGenerator<Types extends SchemaTypes> {
|
|||||||
modelName: Name,
|
modelName: Name,
|
||||||
) {
|
) {
|
||||||
return this.builder.args((t) => ({
|
return this.builder.args((t) => ({
|
||||||
where: t.field({ type: this.getWhereUnique(modelName), required: true }),
|
where: t.field({
|
||||||
|
type: this.getWhereUnique(modelName),
|
||||||
|
required: true,
|
||||||
|
}),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { ApolloDriverConfig } from '@nestjs/apollo';
|
import { ApolloDriverConfig } from '@nestjs/apollo';
|
||||||
import { Global, MiddlewareConsumer, Module } from '@nestjs/common';
|
import { Global, MiddlewareConsumer, Module } from '@nestjs/common';
|
||||||
import { GraphQLModule } from '@nestjs/graphql';
|
import { GraphQLModule } from '@nestjs/graphql';
|
||||||
import { ConfigModule } from '@nestjs/config';
|
|
||||||
import { PothosModule } from '@smatch-corp/nestjs-pothos';
|
import { PothosModule } from '@smatch-corp/nestjs-pothos';
|
||||||
import { PothosApolloDriver } from '@smatch-corp/nestjs-pothos-apollo-driver';
|
import { PothosApolloDriver } from '@smatch-corp/nestjs-pothos-apollo-driver';
|
||||||
import { Builder } from './graphql.builder';
|
import { Builder } from './graphql.builder';
|
||||||
@@ -32,7 +31,6 @@ import { UploadedFileModule } from '../UploadedFile/uploadedfile.module';
|
|||||||
@Global()
|
@Global()
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
ConfigModule.forRoot(),
|
|
||||||
PrismaModule,
|
PrismaModule,
|
||||||
UserModule,
|
UserModule,
|
||||||
CenterModule,
|
CenterModule,
|
||||||
@@ -63,6 +61,7 @@ import { UploadedFileModule } from '../UploadedFile/uploadedfile.module';
|
|||||||
GraphQLModule.forRoot<ApolloDriverConfig>({
|
GraphQLModule.forRoot<ApolloDriverConfig>({
|
||||||
driver: PothosApolloDriver,
|
driver: PothosApolloDriver,
|
||||||
path: process.env.API_PATH + '/graphql',
|
path: process.env.API_PATH + '/graphql',
|
||||||
|
debug: process.env.NODE_ENV === 'development',
|
||||||
playground: true,
|
playground: true,
|
||||||
introspection: true,
|
introspection: true,
|
||||||
installSubscriptionHandlers: true,
|
installSubscriptionHandlers: true,
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ export class MessageSchema extends PothosSchema {
|
|||||||
id: t.exposeID('id'),
|
id: t.exposeID('id'),
|
||||||
senderId: t.exposeID('senderId'),
|
senderId: t.exposeID('senderId'),
|
||||||
chatRoomId: t.exposeID('chatRoomId'),
|
chatRoomId: t.exposeID('chatRoomId'),
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
message: t.expose('message', { type: 'Json' as any }),
|
message: t.expose('message', { type: 'Json' as any }),
|
||||||
sentAt: t.expose('sentAt', { type: 'DateTime' }),
|
sentAt: t.expose('sentAt', { type: 'DateTime' }),
|
||||||
sender: t.relation('sender'),
|
sender: t.relation('sender'),
|
||||||
@@ -38,7 +39,7 @@ export class MessageSchema extends PothosSchema {
|
|||||||
message: t.prismaField({
|
message: t.prismaField({
|
||||||
type: this.message(),
|
type: this.message(),
|
||||||
args: this.builder.generator.findUniqueArgs('Message'),
|
args: this.builder.generator.findUniqueArgs('Message'),
|
||||||
resolve: async (query, root, args, ctx, info) => {
|
resolve: async (query, root, args) => {
|
||||||
return await this.prisma.message.findUnique({
|
return await this.prisma.message.findUnique({
|
||||||
...query,
|
...query,
|
||||||
where: args.where,
|
where: args.where,
|
||||||
@@ -48,7 +49,7 @@ export class MessageSchema extends PothosSchema {
|
|||||||
messages: t.prismaField({
|
messages: t.prismaField({
|
||||||
type: [this.message()],
|
type: [this.message()],
|
||||||
args: this.builder.generator.findManyArgs('Message'),
|
args: this.builder.generator.findManyArgs('Message'),
|
||||||
resolve: async (query, root, args, ctx, info) => {
|
resolve: async (query, root, args) => {
|
||||||
return await this.prisma.message.findMany({
|
return await this.prisma.message.findMany({
|
||||||
...query,
|
...query,
|
||||||
skip: args.skip ?? 0,
|
skip: args.skip ?? 0,
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
import { Module, Global } from '@nestjs/common';
|
import { Module, Global } from '@nestjs/common';
|
||||||
import { MinioService } from './minio.service';
|
import { MinioService } from './minio.service';
|
||||||
import { NestMinioModule } from 'nestjs-minio';
|
import { NestMinioModule } from 'nestjs-minio';
|
||||||
import { ConfigModule } from '@nestjs/config';
|
|
||||||
@Global()
|
@Global()
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
ConfigModule.forRoot(),
|
|
||||||
NestMinioModule.register({
|
NestMinioModule.register({
|
||||||
endPoint: process.env.MINIO_ENDPOINT ?? '10.0.27.1',
|
endPoint: process.env.MINIO_ENDPOINT ?? '10.0.27.1',
|
||||||
accessKey: process.env.MINIO_ACCESS_KEY ?? 'minioadmin',
|
accessKey: process.env.MINIO_ACCESS_KEY ?? 'minioadmin',
|
||||||
secretKey: process.env.MINIO_SECRET_KEY ?? 'minioadmin',
|
secretKey: process.env.MINIO_SECRET_KEY ?? 'minioadmin',
|
||||||
useSSL: true,
|
useSSL: true,
|
||||||
|
isGlobal: true,
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
providers: [MinioService],
|
providers: [MinioService],
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ export class MinioService {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
async uploadFile(file: FileUpload, category: string) {
|
async uploadFile(file: FileUpload, category: string) {
|
||||||
const { mimetype, createReadStream, encoding } = await file;
|
// sonar ignore next
|
||||||
|
const { mimetype, createReadStream } = await file;
|
||||||
const filename = this.fileName();
|
const filename = this.fileName();
|
||||||
const Name = `${category}/${filename}`;
|
const Name = `${category}/${filename}`;
|
||||||
const fileBuffer = createReadStream();
|
const fileBuffer = createReadStream();
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ export class ResumeSchema extends PothosSchema {
|
|||||||
resumes: t.prismaField({
|
resumes: t.prismaField({
|
||||||
type: [this.resume()],
|
type: [this.resume()],
|
||||||
args: this.builder.generator.findManyArgs('Resume'),
|
args: this.builder.generator.findManyArgs('Resume'),
|
||||||
resolve: async (query, root, args, ctx, info) => {
|
resolve: async (query, root, args) => {
|
||||||
return await this.prisma.resume.findMany({
|
return await this.prisma.resume.findMany({
|
||||||
...query,
|
...query,
|
||||||
skip: args.skip ?? undefined,
|
skip: args.skip ?? undefined,
|
||||||
@@ -80,7 +80,7 @@ export class ResumeSchema extends PothosSchema {
|
|||||||
resume: t.prismaField({
|
resume: t.prismaField({
|
||||||
type: this.resume(),
|
type: this.resume(),
|
||||||
args: this.builder.generator.findUniqueArgs('Resume'),
|
args: this.builder.generator.findUniqueArgs('Resume'),
|
||||||
resolve: async (query, root, args, ctx, info) => {
|
resolve: async (query, root, args) => {
|
||||||
const resume = await this.prisma.resume.findUnique({
|
const resume = await this.prisma.resume.findUnique({
|
||||||
...query,
|
...query,
|
||||||
where: args.where,
|
where: args.where,
|
||||||
@@ -92,7 +92,7 @@ export class ResumeSchema extends PothosSchema {
|
|||||||
resumeFile: t.prismaField({
|
resumeFile: t.prismaField({
|
||||||
type: this.resumeFile(),
|
type: this.resumeFile(),
|
||||||
args: this.builder.generator.findUniqueArgs('ResumeFile'),
|
args: this.builder.generator.findUniqueArgs('ResumeFile'),
|
||||||
resolve: async (query, root, args, ctx, info) => {
|
resolve: async (query, root, args) => {
|
||||||
const resumeFile = await this.prisma.resumeFile.findUnique({
|
const resumeFile = await this.prisma.resumeFile.findUnique({
|
||||||
...query,
|
...query,
|
||||||
where: args.where,
|
where: args.where,
|
||||||
@@ -111,7 +111,7 @@ export class ResumeSchema extends PothosSchema {
|
|||||||
resumeFiles: t.prismaField({
|
resumeFiles: t.prismaField({
|
||||||
type: [this.resumeFile()],
|
type: [this.resumeFile()],
|
||||||
args: this.builder.generator.findManyArgs('ResumeFile'),
|
args: this.builder.generator.findManyArgs('ResumeFile'),
|
||||||
resolve: async (query, root, args, ctx, info) => {
|
resolve: async (query, root, args) => {
|
||||||
const resumeFiles = await this.prisma.resumeFile.findMany({
|
const resumeFiles = await this.prisma.resumeFile.findMany({
|
||||||
...query,
|
...query,
|
||||||
skip: args.skip ?? undefined,
|
skip: args.skip ?? undefined,
|
||||||
@@ -135,50 +135,6 @@ export class ResumeSchema extends PothosSchema {
|
|||||||
|
|
||||||
// Mutations section
|
// Mutations section
|
||||||
this.builder.mutationFields((t) => ({
|
this.builder.mutationFields((t) => ({
|
||||||
// createResume: t.prismaField({
|
|
||||||
// type: this.resume(),
|
|
||||||
// args: {
|
|
||||||
// userId: t.arg({
|
|
||||||
// type: 'String',
|
|
||||||
// required: true,
|
|
||||||
// }),
|
|
||||||
// centerId: t.arg({
|
|
||||||
// type: 'String',
|
|
||||||
// required: true,
|
|
||||||
// }),
|
|
||||||
// resumeFile: t.arg({
|
|
||||||
// type: 'Upload',
|
|
||||||
// required: true,
|
|
||||||
// }),
|
|
||||||
// },
|
|
||||||
// resolve: async (query, root, args, ctx, info) => {
|
|
||||||
// const { userId, centerId, resumeFile } = args;
|
|
||||||
// const { mimetype } = await resumeFile;
|
|
||||||
// const { filename } = await this.minioService.uploadFile(
|
|
||||||
// resumeFile,
|
|
||||||
// 'resumes',
|
|
||||||
// );
|
|
||||||
// const fileUrl = await this.minioService.getFileUrl(
|
|
||||||
// filename,
|
|
||||||
// 'resumes',
|
|
||||||
// );
|
|
||||||
// const resume = await this.prisma.resume.create({
|
|
||||||
// data: {
|
|
||||||
// userId,
|
|
||||||
// centerId,
|
|
||||||
// ResumeFile: {
|
|
||||||
// create: {
|
|
||||||
// fileUrl,
|
|
||||||
// type: mimetype,
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
|
|
||||||
// return resume;
|
|
||||||
// },
|
|
||||||
// }),
|
|
||||||
|
|
||||||
upsertResume: t.prismaField({
|
upsertResume: t.prismaField({
|
||||||
type: this.resume(),
|
type: this.resume(),
|
||||||
args: {
|
args: {
|
||||||
@@ -195,7 +151,7 @@ export class ResumeSchema extends PothosSchema {
|
|||||||
required: true,
|
required: true,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
resolve: async (query, root, args, ctx, info) => {
|
resolve: async (query, root, args) => {
|
||||||
const { resumeFile } = args;
|
const { resumeFile } = args;
|
||||||
const { mimetype } = await resumeFile;
|
const { mimetype } = await resumeFile;
|
||||||
const { filename } = await this.minioService.uploadFile(
|
const { filename } = await this.minioService.uploadFile(
|
||||||
@@ -207,9 +163,6 @@ export class ResumeSchema extends PothosSchema {
|
|||||||
'resumes',
|
'resumes',
|
||||||
);
|
);
|
||||||
const { userId, centerId } = args;
|
const { userId, centerId } = args;
|
||||||
if (!userId || !centerId) {
|
|
||||||
throw new Error('userId and centerId are required');
|
|
||||||
}
|
|
||||||
const resume = await this.prisma.resume.upsert({
|
const resume = await this.prisma.resume.upsert({
|
||||||
...query,
|
...query,
|
||||||
where: {
|
where: {
|
||||||
|
|||||||
@@ -94,7 +94,9 @@ export class ServiceSchema extends PothosSchema {
|
|||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
resolve: async (query, root, args, ctx, info) => {
|
resolve: async (query, root, args, ctx, info) => {
|
||||||
return await this.prisma.service.create({ data: args.input });
|
return await this.prisma.service.create({
|
||||||
|
data: args.input,
|
||||||
|
});
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
updateService: t.prismaField({
|
updateService: t.prismaField({
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ export class UploadedFileSchema extends PothosSchema {
|
|||||||
uploadedFile: t.prismaField({
|
uploadedFile: t.prismaField({
|
||||||
type: this.uploadedFile(),
|
type: this.uploadedFile(),
|
||||||
args: this.builder.generator.findUniqueArgs('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({
|
const file = await this.prisma.uploadedFile.findUnique({
|
||||||
...query,
|
...query,
|
||||||
where: args.where,
|
where: args.where,
|
||||||
@@ -66,7 +66,7 @@ export class UploadedFileSchema extends PothosSchema {
|
|||||||
uploadedFiles: t.prismaField({
|
uploadedFiles: t.prismaField({
|
||||||
type: [this.uploadedFile()],
|
type: [this.uploadedFile()],
|
||||||
args: this.builder.generator.findManyArgs('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({
|
const files = await this.prisma.uploadedFile.findMany({
|
||||||
...query,
|
...query,
|
||||||
skip: args.skip ?? 0,
|
skip: args.skip ?? 0,
|
||||||
@@ -105,7 +105,7 @@ export class UploadedFileSchema extends PothosSchema {
|
|||||||
required: true,
|
required: true,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
resolve: async (query, root, args, ctx, info) => {
|
resolve: async (query, root, args) => {
|
||||||
const user = await this.prisma.user.findUnique({
|
const user = await this.prisma.user.findUnique({
|
||||||
where: {
|
where: {
|
||||||
id: args.userId,
|
id: args.userId,
|
||||||
@@ -114,16 +114,16 @@ export class UploadedFileSchema extends PothosSchema {
|
|||||||
if (!user) {
|
if (!user) {
|
||||||
throw new Error('User not found');
|
throw new Error('User not found');
|
||||||
}
|
}
|
||||||
// convert graphql upload to file
|
|
||||||
// upload file to minio
|
|
||||||
const { filename, mimetype } = await this.minioService.uploadFile(
|
const { filename, mimetype } = await this.minioService.uploadFile(
|
||||||
args.file,
|
args.file,
|
||||||
'files',
|
'files',
|
||||||
);
|
);
|
||||||
// getFileUrl
|
if (!mimetype) {
|
||||||
let fileUrl = await this.minioService.getFileUrl(filename, 'files');
|
throw new Error('File type not supported');
|
||||||
|
}
|
||||||
|
const fileUrl = await this.minioService.getFileUrl(filename, 'files');
|
||||||
if (!fileUrl) {
|
if (!fileUrl) {
|
||||||
fileUrl = '';
|
throw new Error('Cannot retrieve file url, please try again later');
|
||||||
}
|
}
|
||||||
const uploadedFile = await this.prisma.uploadedFile.create({
|
const uploadedFile = await this.prisma.uploadedFile.create({
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
@@ -5,6 +5,13 @@ import { ClerkModule } from './Clerk/clerk.module';
|
|||||||
import { RestfulModule } from './Restful/restful.module';
|
import { RestfulModule } from './Restful/restful.module';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [ConfigModule.forRoot(), GraphqlModule, ClerkModule, RestfulModule],
|
imports: [
|
||||||
|
ConfigModule.forRoot({
|
||||||
|
isGlobal: true,
|
||||||
|
}),
|
||||||
|
GraphqlModule,
|
||||||
|
ClerkModule,
|
||||||
|
RestfulModule,
|
||||||
|
],
|
||||||
})
|
})
|
||||||
export class AppModule {}
|
export class AppModule {}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user