chore: update configuration and improve schema imports
- Updated biome.json to include "graphql.d.ts" in the ignored files list. - Updated subproject commit reference in epess-database to the latest version. - Removed unused script from package.json and streamlined module file extensions in tsconfig.json. - Consolidated exclude patterns in tsconfig.build.json for clarity. - Refactored imports across multiple schema files for consistency and improved readability. - Enhanced various schema files by ensuring proper import order and removing redundant code. - Improved error handling and data integrity checks in several service and schema files.
This commit is contained in:
12
.vscode/launch.json
vendored
12
.vscode/launch.json
vendored
@@ -8,9 +8,7 @@
|
||||
"name": "Attach by Process ID",
|
||||
"processId": "${command:PickProcess}",
|
||||
"request": "attach",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"skipFiles": ["<node_internals>/**"],
|
||||
"type": "node"
|
||||
},
|
||||
{
|
||||
@@ -18,14 +16,10 @@
|
||||
"request": "launch",
|
||||
"name": "Launch Program",
|
||||
"runtimeExecutable": "C:\\Users\\AliensVN\\AppData\\Roaming\\fnm\\node-versions\\v22.6.0\\installation\\node.exe",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"skipFiles": ["<node_internals>/**"],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"program": "${file}",
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/**/*.js"
|
||||
]
|
||||
"outFiles": ["${workspaceFolder}/**/*.js"]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
},
|
||||
"files": {
|
||||
"ignoreUnknown": false,
|
||||
"ignore": ["dist"]
|
||||
"ignore": ["dist", "graphql.d.ts"]
|
||||
},
|
||||
"formatter": {
|
||||
"enabled": true,
|
||||
|
||||
Submodule epess-database updated: 2ed462351c...7c509dc832
15
package.json
15
package.json
@@ -7,7 +7,6 @@
|
||||
"license": "UNLICENSED",
|
||||
"scripts": {
|
||||
"build": "nest build",
|
||||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"start": "nest start",
|
||||
"start:dev": "nest start --watch",
|
||||
"start:debug": "nest start --debug --watch",
|
||||
@@ -20,8 +19,8 @@
|
||||
"prisma:seed": "npx prisma db seed --schema=./epess-database/prisma/schema.prisma",
|
||||
"prisma:format": "npx prisma format --schema=./epess-database/prisma/schema.prisma",
|
||||
"prisma:studio": "dotenv -e .env -- npx prisma studio --schema=./epess-database/prisma/schema.prisma",
|
||||
"biome:check": "biome check",
|
||||
"biome:fix": "biome fix --write",
|
||||
"biome:check": "biome check --write --unsafe",
|
||||
"biome:format": "biome format --write",
|
||||
"test": "jest",
|
||||
"test:watch": "jest --watch",
|
||||
"test:cov": "jest --coverage",
|
||||
@@ -138,19 +137,13 @@
|
||||
"@css-inline/css-inline-linux-x64-musl": "^0.14.3"
|
||||
},
|
||||
"jest": {
|
||||
"moduleFileExtensions": [
|
||||
"js",
|
||||
"json",
|
||||
"ts"
|
||||
],
|
||||
"moduleFileExtensions": ["js", "json", "ts"],
|
||||
"rootDir": "src",
|
||||
"testRegex": ".*\\.spec\\.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
},
|
||||
"collectCoverageFrom": [
|
||||
"**/*.(t|j)s"
|
||||
],
|
||||
"collectCoverageFrom": ["**/*.(t|j)s"],
|
||||
"coverageDirectory": "../coverage",
|
||||
"testEnvironment": "node"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { AdminNoteSchema } from './adminnote.schema'
|
||||
import { Module } from '@nestjs/common'
|
||||
import { AdminNoteSchema } from './adminnote.schema'
|
||||
|
||||
@Module({
|
||||
providers: [AdminNoteSchema],
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
import { Inject, Injectable } from '@nestjs/common'
|
||||
import {
|
||||
Pothos,
|
||||
PothosRef,
|
||||
PothosSchema,
|
||||
SchemaBuilderToken,
|
||||
} from '@smatch-corp/nestjs-pothos'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { Builder } from '../Graphql/graphql.builder'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
|
||||
@@ -43,20 +38,16 @@ export class AdminNoteSchema extends PothosSchema {
|
||||
description: 'The date and time the admin note was last updated.',
|
||||
}),
|
||||
centerId: t.exposeString('centerId', {
|
||||
description:
|
||||
'The ID of the center the admin note is associated with.',
|
||||
description: 'The ID of the center the admin note is associated with.',
|
||||
}),
|
||||
serviceId: t.exposeString('serviceId', {
|
||||
description:
|
||||
'The ID of the service the admin note is associated with.',
|
||||
description: 'The ID of the service the admin note is associated with.',
|
||||
}),
|
||||
mentorId: t.exposeString('mentorId', {
|
||||
description:
|
||||
'The ID of the mentor the admin note is associated with.',
|
||||
description: 'The ID of the mentor the admin note is associated with.',
|
||||
}),
|
||||
resumeId: t.exposeString('resumeId', {
|
||||
description:
|
||||
'The ID of the resume the admin note is associated with.',
|
||||
description: 'The ID of the resume the admin note is associated with.',
|
||||
}),
|
||||
mentor: t.relation('mentor', {
|
||||
description: 'The mentor the admin note is associated with.',
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Module } from '@nestjs/common'
|
||||
import { AnalyticSchema } from './analytic.schema'
|
||||
import { ServiceSchema } from 'src/Service/service.schema'
|
||||
import { CenterSchema } from 'src/Center/center.schema'
|
||||
import { OrderSchema } from 'src/Order/order.schema'
|
||||
import { PayosModule } from 'src/Payos/payos.module'
|
||||
import { ServiceSchema } from 'src/Service/service.schema'
|
||||
import { AnalyticSchema } from './analytic.schema'
|
||||
|
||||
@Module({
|
||||
imports: [PayosModule],
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { Inject, Injectable } from '@nestjs/common'
|
||||
import { OrderStatus, Prisma, Role, ServiceStatus } from '@prisma/client'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { DateTimeUtils } from 'src/common/utils/datetime.utils'
|
||||
import { CenterSchema } from 'src/Center/center.schema'
|
||||
import { Builder } from 'src/Graphql/graphql.builder'
|
||||
import { OrderSchema } from 'src/Order/order.schema'
|
||||
import { PrismaService } from 'src/Prisma/prisma.service'
|
||||
import { ServiceSchema } from 'src/Service/service.schema'
|
||||
import { CenterSchema } from 'src/Center/center.schema'
|
||||
import { OrderSchema } from 'src/Order/order.schema'
|
||||
import { DateTimeUtils } from 'src/common/utils/datetime.utils'
|
||||
@Injectable()
|
||||
export class AnalyticSchema extends PothosSchema {
|
||||
constructor(
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
import { Inject, Injectable } from '@nestjs/common'
|
||||
import {
|
||||
PothosRef,
|
||||
PothosSchema,
|
||||
SchemaBuilderToken,
|
||||
} from '@smatch-corp/nestjs-pothos'
|
||||
import { PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { Builder } from 'src/Graphql/graphql.builder'
|
||||
import { AppConfigService } from './appconfig.service'
|
||||
import { PrismaService } from 'src/Prisma/prisma.service'
|
||||
import { AppConfigService } from './appconfig.service'
|
||||
|
||||
@Injectable()
|
||||
export class AppConfigSchema extends PothosSchema {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Injectable, OnModuleInit } from '@nestjs/common'
|
||||
|
||||
import { PrismaService } from 'src/Prisma/prisma.service'
|
||||
import { ConfigConstants } from './appconfig.constant'
|
||||
import { Config } from '@prisma/client'
|
||||
import { PrismaService } from 'src/Prisma/prisma.service'
|
||||
import { StringUtils } from 'src/common/utils/string.utils'
|
||||
import { ConfigConstants } from './appconfig.constant'
|
||||
|
||||
@Injectable()
|
||||
export class AppConfigService implements OnModuleInit {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { Inject, Injectable, Logger } from '@nestjs/common'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { Builder } from '../Graphql/graphql.builder'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
import { MinioService } from '../Minio/minio.service'
|
||||
import { CenterStatus, Role } from '@prisma/client'
|
||||
import { MailService } from '../Mail/mail.service'
|
||||
import { clerkClient } from '@clerk/express'
|
||||
import { Inject, Injectable, Logger } from '@nestjs/common'
|
||||
import { CenterStatus, Role } from '@prisma/client'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { RedisService } from 'src/Redis/redis.service'
|
||||
import { Builder } from '../Graphql/graphql.builder'
|
||||
import { MailService } from '../Mail/mail.service'
|
||||
import { MinioService } from '../Minio/minio.service'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
|
||||
@Injectable()
|
||||
export class CenterSchema extends PothosSchema {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { CenterMentorSchema } from './centermentor.schema'
|
||||
import { Module } from '@nestjs/common'
|
||||
import { UserModule } from 'src/User/user.module'
|
||||
import { CenterMentorSchema } from './centermentor.schema'
|
||||
|
||||
@Module({
|
||||
imports: [UserModule],
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { Inject, Injectable } from '@nestjs/common'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { Builder } from '../Graphql/graphql.builder'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
import { MailService } from '../Mail/mail.service'
|
||||
import { JwtUtils } from '../common/utils/jwt.utils'
|
||||
import { clerkClient } from '@clerk/express'
|
||||
import { RedisService } from 'src/Redis/redis.service'
|
||||
import { Inject, Injectable } from '@nestjs/common'
|
||||
import { Role } from '@prisma/client'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { RedisService } from 'src/Redis/redis.service'
|
||||
import { Builder } from '../Graphql/graphql.builder'
|
||||
import { MailService } from '../Mail/mail.service'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
import { JwtUtils } from '../common/utils/jwt.utils'
|
||||
@Injectable()
|
||||
export class CenterMentorSchema extends PothosSchema {
|
||||
constructor(
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
import { Inject, Injectable } from '@nestjs/common'
|
||||
import {
|
||||
Pothos,
|
||||
PothosRef,
|
||||
PothosSchema,
|
||||
SchemaBuilderToken,
|
||||
} from '@smatch-corp/nestjs-pothos'
|
||||
import { ChatRoomType } from '@prisma/client'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { Builder } from '../Graphql/graphql.builder'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
import { ChatRoomType } from '@prisma/client'
|
||||
|
||||
@Injectable()
|
||||
export class ChatroomSchema extends PothosSchema {
|
||||
@@ -86,8 +81,7 @@ export class ChatroomSchema extends PothosSchema {
|
||||
|
||||
chatRooms: t.prismaField({
|
||||
type: [this.chatRoom()],
|
||||
description:
|
||||
'Retrieve a list of chat rooms with optional filtering, ordering, and pagination.',
|
||||
description: 'Retrieve a list of chat rooms with optional filtering, ordering, and pagination.',
|
||||
args: this.builder.generator.findManyArgs('ChatRoom'),
|
||||
resolve: async (query, _root, args, _ctx, _info) => {
|
||||
return await this.prisma.chatRoom.findMany({
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
// clerk-auth.guard.ts
|
||||
import {
|
||||
Injectable,
|
||||
CanActivate,
|
||||
ExecutionContext,
|
||||
Inject,
|
||||
UnauthorizedException,
|
||||
} from '@nestjs/common'
|
||||
import Clerk from '@clerk/express'
|
||||
// clerk-auth.guard.ts
|
||||
import { CanActivate, ExecutionContext, Inject, Injectable, UnauthorizedException } from '@nestjs/common'
|
||||
import { GqlExecutionContext } from '@nestjs/graphql'
|
||||
|
||||
@Injectable()
|
||||
@@ -44,9 +38,7 @@ export class ClerkAuthGuard implements CanActivate {
|
||||
|
||||
return true
|
||||
} catch (error: unknown) {
|
||||
throw new UnauthorizedException(
|
||||
error instanceof Error ? error.message : 'Unknown error',
|
||||
)
|
||||
throw new UnauthorizedException(error instanceof Error ? error.message : 'Unknown error')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Controller, Get, Post, Put, Delete, Param, Body, Headers } from '@nestjs/common'
|
||||
import { Body, Controller, Delete, Get, Headers, Param, Post, Put } from '@nestjs/common'
|
||||
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'
|
||||
import { ClerkService } from './clerk.service'
|
||||
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger'
|
||||
@ApiTags('Clerk')
|
||||
@Controller('clerk')
|
||||
export class ClerkController {
|
||||
@@ -9,6 +9,7 @@ export class ClerkController {
|
||||
@Post('webhook')
|
||||
@ApiOperation({ summary: 'Clerk Webhook' })
|
||||
@ApiResponse({ status: 200, description: 'Webhook created successfully' })
|
||||
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
||||
webhook(@Body() body: any) {
|
||||
return this.clerkService.webhook(body)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Module, Global } from '@nestjs/common'
|
||||
import Clerk from '@clerk/express'
|
||||
import { ClerkService } from './clerk.service'
|
||||
import { Global, Module } from '@nestjs/common'
|
||||
import ClerkController from './clerk.controller'
|
||||
import { ClerkService } from './clerk.service'
|
||||
@Global()
|
||||
@Module({
|
||||
providers: [
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Injectable, Logger } from '@nestjs/common'
|
||||
|
||||
import { WebhookEventType, clerkClient } from '@clerk/express'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
import { clerkClient, WebhookEventType } from '@clerk/express'
|
||||
import { RedisService } from '../Redis/redis.service'
|
||||
export interface ClerkResponse {}
|
||||
@Injectable()
|
||||
@@ -10,6 +10,7 @@ export class ClerkService {
|
||||
private readonly prisma: PrismaService,
|
||||
private readonly redis: RedisService,
|
||||
) {}
|
||||
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
||||
async webhook(body: any) {
|
||||
// get the event type
|
||||
const eventType = body.type
|
||||
@@ -18,6 +19,7 @@ export class ClerkService {
|
||||
return { message: `Webhook received: ${eventType}` }
|
||||
}
|
||||
// dispatch the event
|
||||
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
||||
async dispatchEvent(eventType: WebhookEventType, data: any) {
|
||||
// event types:
|
||||
// user.created
|
||||
@@ -55,10 +57,14 @@ export class ClerkService {
|
||||
this.eventEmailCreated(data)
|
||||
}
|
||||
}
|
||||
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
||||
async eventUserCreated(data: any) {
|
||||
const primary_email_address_id = data.primary_email_address_id
|
||||
// get primary email address on email_addresses by querying email_addresses with primary_email_address_id
|
||||
let primary_email_address = data.email_addresses.find((email: any) => email.id === primary_email_address_id)
|
||||
let primary_email_address = data.email_addresses.find(
|
||||
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
||||
(email: any) => email.id === primary_email_address_id,
|
||||
)
|
||||
if (!primary_email_address) {
|
||||
primary_email_address = ''
|
||||
}
|
||||
@@ -87,6 +93,7 @@ export class ClerkService {
|
||||
}
|
||||
}
|
||||
|
||||
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
||||
async eventUserUpdated(data: any) {
|
||||
const user_id = data.id
|
||||
const name = `${data.first_name} ${data.last_name}`
|
||||
@@ -96,6 +103,7 @@ export class ClerkService {
|
||||
})
|
||||
}
|
||||
|
||||
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
||||
async eventSessionCreated(data: any) {
|
||||
// check if user exists in database or create user
|
||||
const user = await this.prisma.user.findUnique({
|
||||
@@ -120,24 +128,28 @@ export class ClerkService {
|
||||
// to do: get session info
|
||||
}
|
||||
|
||||
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
||||
async eventSessionRevoked(data: any) {
|
||||
Logger.log(data, 'ClerkService')
|
||||
// invalidate session from redis
|
||||
await this.redis.del(`session:${data.session_id}`)
|
||||
}
|
||||
|
||||
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
||||
async eventSessionRemoved(data: any) {
|
||||
Logger.log(data, 'ClerkService')
|
||||
// invalidate session from redis
|
||||
await this.redis.del(`session:${data.session_id}`)
|
||||
}
|
||||
|
||||
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
||||
async eventSessionEnded(data: any) {
|
||||
Logger.log(data, 'ClerkService')
|
||||
// invalidate session from redis
|
||||
await this.redis.del(`session:${data.session_id}`)
|
||||
}
|
||||
|
||||
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
||||
async eventEmailCreated(data: any) {
|
||||
Logger.log(data, 'ClerkService')
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Module } from '@nestjs/common'
|
||||
import { CollaborationSessionSchema } from './collaborationsession.schema'
|
||||
import { LiveKitModule } from 'src/LiveKit/livekit.module'
|
||||
import { LiveKitService } from 'src/LiveKit/livekit.service'
|
||||
import { LiveKitRoomService } from 'src/LiveKit/livekit.room.service'
|
||||
import { LiveKitService } from 'src/LiveKit/livekit.service'
|
||||
import { CollaborationSessionSchema } from './collaborationsession.schema'
|
||||
|
||||
@Module({
|
||||
imports: [LiveKitModule],
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { Inject, Injectable, Logger } from '@nestjs/common'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { CollaborationSession, Role, ScheduleDateStatus } from '@prisma/client'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
|
||||
import { Builder, SchemaContext } from 'src/Graphql/graphql.builder'
|
||||
import { LiveKitRoomService } from 'src/LiveKit/livekit.room.service'
|
||||
import { LiveKitService } from 'src/LiveKit/livekit.service'
|
||||
import { PrismaService } from 'src/Prisma/prisma.service'
|
||||
import { DateTimeUtils } from 'src/common/utils/datetime.utils'
|
||||
import { LiveKitService } from 'src/LiveKit/livekit.service'
|
||||
import { LiveKitRoomService } from 'src/LiveKit/livekit.room.service'
|
||||
@Injectable()
|
||||
export class CollaborationSessionSchema extends PothosSchema {
|
||||
constructor(
|
||||
@@ -283,9 +283,7 @@ export class CollaborationSessionSchema extends PothosSchema {
|
||||
},
|
||||
})
|
||||
if (!collaborationSession) throw new Error('Collaboration session not found')
|
||||
return ctx.websocket.pubSub.asyncIterableIterator(
|
||||
`collaborationSessionUpdated:${collaborationSession.id}`,
|
||||
)
|
||||
return ctx.websocket.pubSub.asyncIterableIterator(`collaborationSessionUpdated:${collaborationSession.id}`)
|
||||
},
|
||||
resolve: async (payload: CollaborationSession) => payload,
|
||||
}),
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Module } from '@nestjs/common'
|
||||
import { ScheduleModule } from '@nestjs/schedule'
|
||||
import { CronService } from './cron.service'
|
||||
import { PubSubModule } from 'src/PubSub/pubsub.module'
|
||||
import { NotificationModule } from 'src/Notification/notification.module'
|
||||
import { PubSubModule } from 'src/PubSub/pubsub.module'
|
||||
import { CronService } from './cron.service'
|
||||
@Module({
|
||||
imports: [ScheduleModule.forRoot(), NotificationModule, PubSubModule],
|
||||
providers: [CronService],
|
||||
|
||||
@@ -2,9 +2,9 @@ import { Injectable, Logger } from '@nestjs/common'
|
||||
import { Cron } from '@nestjs/schedule'
|
||||
import { CronExpression } from '@nestjs/schedule'
|
||||
import { OrderStatus, PaymentStatus, ScheduleDateStatus, ScheduleStatus, ServiceStatus } from '@prisma/client'
|
||||
import { DateTimeUtils } from 'src/common/utils/datetime.utils'
|
||||
import { NotificationService } from 'src/Notification/notification.service'
|
||||
import { PrismaService } from 'src/Prisma/prisma.service'
|
||||
import { DateTimeUtils } from 'src/common/utils/datetime.utils'
|
||||
|
||||
@Injectable()
|
||||
export class CronService {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Module } from '@nestjs/common'
|
||||
import { DocumentService } from './document.service'
|
||||
import { DocumentSchema } from './document.schema'
|
||||
import { OpenaiModule } from 'src/OpenAI/openai.module'
|
||||
import { DocumentSchema } from './document.schema'
|
||||
import { DocumentService } from './document.service'
|
||||
@Module({
|
||||
imports: [OpenaiModule],
|
||||
providers: [DocumentService, DocumentSchema],
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { Inject, Injectable, Logger } from '@nestjs/common'
|
||||
import { Document } from '@prisma/client'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import Delta from 'quill-delta'
|
||||
import { MinioService } from 'src/Minio/minio.service'
|
||||
import { Builder, SchemaContext } from '../Graphql/graphql.builder'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
import { DocumentEvent } from './document.event'
|
||||
import { Document } from '@prisma/client'
|
||||
import { DocumentDelta } from './document.type'
|
||||
import Delta from 'quill-delta'
|
||||
import { MinioService } from 'src/Minio/minio.service'
|
||||
@Injectable()
|
||||
export class DocumentSchema extends PothosSchema {
|
||||
constructor(
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { forwardRef, Inject, Injectable } from '@nestjs/common'
|
||||
import { Inject, Injectable, forwardRef } from '@nestjs/common'
|
||||
|
||||
import { Logger } from '@nestjs/common'
|
||||
import Delta, { Op } from 'quill-delta'
|
||||
import { PrismaService } from 'src/Prisma/prisma.service'
|
||||
import { MinioService } from '../Minio/minio.service'
|
||||
import { DocumentDelta } from './document.type'
|
||||
import { Logger } from '@nestjs/common'
|
||||
import { PrismaService } from 'src/Prisma/prisma.service'
|
||||
@Injectable()
|
||||
export class DocumentService {
|
||||
constructor(
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
import { JSONObjectResolver } from 'graphql-scalars'
|
||||
import PrismaPlugin, { PothosPrismaDatamodel, PrismaClient } from '@pothos/plugin-prisma'
|
||||
import { Request, Response } from 'express'
|
||||
import SmartSubscriptionPlugin, { subscribeOptionsFromIterator } from '@pothos/plugin-smart-subscriptions'
|
||||
import ZodPlugin from '@pothos/plugin-zod'
|
||||
import { Injectable, Logger } from '@nestjs/common'
|
||||
import SchemaBuilder from '@pothos/core'
|
||||
import AuthzPlugin from '@pothos/plugin-authz'
|
||||
import ErrorsPlugin from '@pothos/plugin-errors'
|
||||
// @ts-expect-error
|
||||
import type { FileUpload } from 'graphql-upload/processRequest.mjs'
|
||||
import PrismaPlugin, { PothosPrismaDatamodel, PrismaClient } from '@pothos/plugin-prisma'
|
||||
import PrismaUtils from '@pothos/plugin-prisma-utils'
|
||||
import RelayPlugin from '@pothos/plugin-relay'
|
||||
import SimpleObjectPlugin from '@pothos/plugin-simple-objects'
|
||||
import SmartSubscriptionPlugin, { subscribeOptionsFromIterator } from '@pothos/plugin-smart-subscriptions'
|
||||
import ZodPlugin from '@pothos/plugin-zod'
|
||||
import { User } from '@prisma/client'
|
||||
import { JsonValue } from '@prisma/client/runtime/library'
|
||||
import { Request, Response } from 'express'
|
||||
import { Kind, ValueNode } from 'graphql'
|
||||
import { JSONObjectResolver } from 'graphql-scalars'
|
||||
import { PubSub } from 'graphql-subscriptions'
|
||||
// @ts-expect-error
|
||||
import GraphQLUpload from 'graphql-upload/GraphQLUpload.mjs'
|
||||
import { Injectable, Logger } from '@nestjs/common'
|
||||
import { PrismaCrudGenerator } from './graphql.generator'
|
||||
import type PrismaTypes from '../types/pothos.generated'
|
||||
import PrismaUtils from '@pothos/plugin-prisma-utils'
|
||||
import { PubSub } from 'graphql-subscriptions'
|
||||
import RelayPlugin from '@pothos/plugin-relay'
|
||||
import SchemaBuilder from '@pothos/core'
|
||||
import SimpleObjectPlugin from '@pothos/plugin-simple-objects'
|
||||
import { User } from '@prisma/client'
|
||||
import { getDatamodel } from '../types/pothos.generated'
|
||||
// @ts-expect-error
|
||||
import type { FileUpload } from 'graphql-upload/processRequest.mjs'
|
||||
import { DateTime } from 'luxon'
|
||||
import { Kind, ValueNode } from 'graphql'
|
||||
import { DateTimeUtils } from '../common/utils/datetime.utils'
|
||||
import { JsonValue } from '@prisma/client/runtime/library'
|
||||
import Delta from 'quill-delta'
|
||||
import { DateTimeUtils } from '../common/utils/datetime.utils'
|
||||
import type PrismaTypes from '../types/pothos.generated'
|
||||
import { getDatamodel } from '../types/pothos.generated'
|
||||
import { PrismaCrudGenerator } from './graphql.generator'
|
||||
|
||||
export type SchemaContext =
|
||||
| {
|
||||
|
||||
@@ -1,52 +1,52 @@
|
||||
import { Global, Logger, Module } from '@nestjs/common'
|
||||
|
||||
import { AdminNoteModule } from '../AdminNote/adminnote.module'
|
||||
import { ApolloDriverConfig } from '@nestjs/apollo'
|
||||
import { AppConfigModule } from '../AppConfig/appconfig.module'
|
||||
import { Builder } from './graphql.builder'
|
||||
import { CategoryModule } from '../Category/category.module'
|
||||
import { CenterMentorModule } from '../CenterMentor/centermentor.module'
|
||||
import { CenterModule } from '../Center/center.module'
|
||||
import { ChatroomModule } from '../ChatRoom/chatroom.module'
|
||||
import { CommonModule } from '../common/common.module'
|
||||
import { ConfigModule } from '@nestjs/config'
|
||||
import { GraphQLModule } from '@nestjs/graphql'
|
||||
import { GraphqlService } from './graphql.service'
|
||||
import { initContextCache } from '@pothos/core'
|
||||
import { PothosModule } from '@smatch-corp/nestjs-pothos'
|
||||
import { PothosApolloDriver } from '@smatch-corp/nestjs-pothos-apollo-driver'
|
||||
import { Request } from 'express'
|
||||
import { RedisPubSub } from 'graphql-redis-subscriptions'
|
||||
import { Context } from 'graphql-ws'
|
||||
import { PersonalMilestoneModule } from 'src/PersonalMilestone/personalmilestone.module'
|
||||
import { AdminNoteModule } from '../AdminNote/adminnote.module'
|
||||
import { AnalyticModule } from '../Analytic/analytic.module'
|
||||
import { AppConfigModule } from '../AppConfig/appconfig.module'
|
||||
import { CategoryModule } from '../Category/category.module'
|
||||
import { CenterModule } from '../Center/center.module'
|
||||
import { CenterMentorModule } from '../CenterMentor/centermentor.module'
|
||||
import { ChatroomModule } from '../ChatRoom/chatroom.module'
|
||||
import { CollaborationSessionModule } from '../CollaborationSession/collaborationsession.module'
|
||||
import { DocumentModule } from '../Document/document.module'
|
||||
import { ManagedServiceModule } from '../ManagedService/managedservice.module'
|
||||
import { MeetingRoomModule } from '../MeetingRoom/meetingroom.module'
|
||||
import { MessageModule } from '../Message/message.module'
|
||||
import { OrderModule } from '../Order/order.module'
|
||||
import { PaymentModule } from '../Payment/payment.module'
|
||||
import { PothosApolloDriver } from '@smatch-corp/nestjs-pothos-apollo-driver'
|
||||
import { PothosModule } from '@smatch-corp/nestjs-pothos'
|
||||
import { PrismaCrudGenerator } from './graphql.generator'
|
||||
import { PrismaModule } from '../Prisma/prisma.module'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
import { PubSubModule } from '../PubSub/pubsub.module'
|
||||
import { PubSubService } from '../PubSub/pubsub.service'
|
||||
import { QuizModule } from '../Quiz/quiz.module'
|
||||
import { RedisModule } from '../Redis/redis.module'
|
||||
import { RedisService } from '../Redis/redis.service'
|
||||
import { RefundTicketModule } from '../RefundTicket/refundticket.module'
|
||||
import { Request } from 'express'
|
||||
import { ResumeModule } from '../Resume/resume.module'
|
||||
import { ScheduleModule } from '../Schedule/schedule.module'
|
||||
import { ServiceModule } from '../Service/service.module'
|
||||
import { ServiceAndCategoryModule } from '../ServiceAndCategory/serviceandcategory.module'
|
||||
import { ServiceFeedbackModule } from '../ServiceFeedback/servicefeedback.module'
|
||||
import { CollaborationSessionModule } from '../CollaborationSession/collaborationsession.module'
|
||||
import { ServiceModule } from '../Service/service.module'
|
||||
import { UploadedFileModule } from '../UploadedFile/uploadedfile.module'
|
||||
import { UserModule } from '../User/user.module'
|
||||
import { WorkshopMeetingRoomModule } from '../WorkshopMeetingRoom/workshopmeetingroom.module'
|
||||
import { WorkshopModule } from '../Workshop/workshop.module'
|
||||
import { WorkshopMeetingRoomModule } from '../WorkshopMeetingRoom/workshopmeetingroom.module'
|
||||
import { WorkshopOrganizationModule } from '../WorkshopOrganization/workshoporganization.module'
|
||||
import { WorkshopSubscriptionModule } from '../WorkshopSubscription/workshopsubscription.module'
|
||||
import { initContextCache } from '@pothos/core'
|
||||
import { RedisPubSub } from 'graphql-redis-subscriptions'
|
||||
import { DocumentModule } from '../Document/document.module'
|
||||
import { Context } from 'graphql-ws'
|
||||
import { AnalyticModule } from '../Analytic/analytic.module'
|
||||
import { MeetingRoomModule } from '../MeetingRoom/meetingroom.module'
|
||||
import { PubSubModule } from '../PubSub/pubsub.module'
|
||||
import { QuizModule } from '../Quiz/quiz.module'
|
||||
import { PubSubService } from '../PubSub/pubsub.service'
|
||||
import { PersonalMilestoneModule } from 'src/PersonalMilestone/personalmilestone.module'
|
||||
import { CommonModule } from '../common/common.module'
|
||||
import { Builder } from './graphql.builder'
|
||||
import { PrismaCrudGenerator } from './graphql.generator'
|
||||
import { GraphqlService } from './graphql.service'
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Inject, Injectable, Logger, UnauthorizedException } from '@nestjs/common'
|
||||
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
import { Request } from 'express'
|
||||
import { clerkClient } from '@clerk/express'
|
||||
import { Request } from 'express'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
|
||||
import { RedisService } from '../Redis/redis.service'
|
||||
|
||||
|
||||
847
src/Graphql/types/graphql.d.ts
vendored
847
src/Graphql/types/graphql.d.ts
vendored
File diff suppressed because it is too large
Load Diff
@@ -2,9 +2,9 @@ import { Injectable } from '@nestjs/common'
|
||||
import {
|
||||
EgressClient,
|
||||
EncodedFileOutput,
|
||||
StreamOutput,
|
||||
EncodedFileType,
|
||||
EncodingOptionsPreset,
|
||||
StreamOutput,
|
||||
// @ts-expect-error
|
||||
} from 'livekit-server-sdk'
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Module, Global } from '@nestjs/common'
|
||||
import { LiveKitService } from './livekit.service'
|
||||
import { LiveKitRoomService } from './livekit.room.service'
|
||||
import { Global, Module } from '@nestjs/common'
|
||||
import { LiveKitEgressService } from './livekit.egress.service'
|
||||
import { LiveKitRoomService } from './livekit.room.service'
|
||||
import { LiveKitService } from './livekit.service'
|
||||
@Global()
|
||||
@Module({
|
||||
providers: [LiveKitService, LiveKitRoomService, LiveKitEgressService],
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import {
|
||||
Room,
|
||||
RoomServiceClient,
|
||||
RoomEgress,
|
||||
AutoTrackEgress,
|
||||
AutoParticipantEgress,
|
||||
EncodedFileType,
|
||||
AutoTrackEgress,
|
||||
EncodedFileOutput,
|
||||
RoomCompositeEgressRequest,
|
||||
EncodedFileType,
|
||||
EncodingOptionsPreset,
|
||||
Room,
|
||||
RoomCompositeEgressRequest,
|
||||
RoomEgress,
|
||||
RoomServiceClient,
|
||||
// @ts-expect-error
|
||||
} from 'livekit-server-sdk'
|
||||
import { LiveKitEgressService } from './livekit.egress.service'
|
||||
import { DateTimeUtils } from 'src/common/utils/datetime.utils'
|
||||
import { LiveKitEgressService } from './livekit.egress.service'
|
||||
|
||||
@Injectable()
|
||||
export class LiveKitRoomService {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { User } from '@prisma/client'
|
||||
import { Injectable, Logger } from '@nestjs/common'
|
||||
import { User } from '@prisma/client'
|
||||
// @ts-expect-error
|
||||
import { RoomServiceClient, AccessToken } from 'livekit-server-sdk'
|
||||
import { AccessToken, RoomServiceClient } from 'livekit-server-sdk'
|
||||
|
||||
@Injectable()
|
||||
export class LiveKitService {
|
||||
|
||||
@@ -2,10 +2,10 @@ import * as path from 'path'
|
||||
|
||||
import { Global, Module } from '@nestjs/common'
|
||||
|
||||
import { MailService } from './mail.service'
|
||||
import { MailerModule } from '@nestjs-modules/mailer'
|
||||
import { OpenaiModule } from '../OpenAI/openai.module'
|
||||
import { PugAdapter } from '@nestjs-modules/mailer/dist/adapters/pug.adapter'
|
||||
import { OpenaiModule } from '../OpenAI/openai.module'
|
||||
import { MailService } from './mail.service'
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Injectable, Logger } from '@nestjs/common'
|
||||
|
||||
import { MailerService } from '@nestjs-modules/mailer'
|
||||
import { OpenaiService } from '../OpenAI/openai.service'
|
||||
import { User } from '@prisma/client'
|
||||
import { OpenaiService } from '../OpenAI/openai.service'
|
||||
|
||||
@Injectable()
|
||||
export class MailService {
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
import { Inject, Injectable } from '@nestjs/common'
|
||||
import {
|
||||
Pothos,
|
||||
PothosRef,
|
||||
PothosSchema,
|
||||
SchemaBuilderToken,
|
||||
} from '@smatch-corp/nestjs-pothos'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { Builder } from '../Graphql/graphql.builder'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Module } from '@nestjs/common'
|
||||
import { MeetingRoomSchema } from './meetingroom.schema'
|
||||
import { LiveKitModule } from 'src/LiveKit/livekit.module'
|
||||
import { MeetingRoomSchema } from './meetingroom.schema'
|
||||
|
||||
@Module({
|
||||
imports: [LiveKitModule],
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Inject, Injectable, Logger } from '@nestjs/common'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { Builder, SchemaContext } from 'src/Graphql/graphql.builder'
|
||||
import { PrismaService } from 'src/Prisma/prisma.service'
|
||||
import { LiveKitService } from 'src/LiveKit/livekit.service'
|
||||
import { MinioService } from 'src/Minio/minio.service'
|
||||
import { PrismaService } from 'src/Prisma/prisma.service'
|
||||
@Injectable()
|
||||
export class MeetingRoomSchema extends PothosSchema {
|
||||
constructor(
|
||||
|
||||
@@ -1,20 +1,10 @@
|
||||
import { Inject, Injectable, Logger } from '@nestjs/common'
|
||||
import {
|
||||
Pothos,
|
||||
PothosRef,
|
||||
PothosSchema,
|
||||
SchemaBuilderToken,
|
||||
} from '@smatch-corp/nestjs-pothos'
|
||||
import { ChatRoomType, Message, MessageContextType, MessageType } from '@prisma/client'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { Builder, SchemaContext } from '../Graphql/graphql.builder'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
import {
|
||||
ChatRoomType,
|
||||
Message,
|
||||
MessageContextType,
|
||||
MessageType,
|
||||
} from '@prisma/client'
|
||||
import { DateTimeUtils } from '../common/utils/datetime.utils'
|
||||
import { PubSubEvent } from '../common/pubsub/pubsub-event'
|
||||
import { DateTimeUtils } from '../common/utils/datetime.utils'
|
||||
|
||||
@Injectable()
|
||||
export class MessageSchema extends PothosSchema {
|
||||
@@ -85,8 +75,7 @@ export class MessageSchema extends PothosSchema {
|
||||
}),
|
||||
messages: t.prismaField({
|
||||
type: [this.message()],
|
||||
description:
|
||||
'Retrieve a list of messages with optional filtering, ordering, and pagination.',
|
||||
description: 'Retrieve a list of messages with optional filtering, ordering, and pagination.',
|
||||
args: this.builder.generator.findManyArgs('Message'),
|
||||
resolve: async (query, _root, args) => {
|
||||
return await this.prisma.message.findMany({
|
||||
@@ -184,16 +173,10 @@ export class MessageSchema extends PothosSchema {
|
||||
})
|
||||
return message
|
||||
})
|
||||
ctx.http.pubSub.publish(
|
||||
`${PubSubEvent.MESSAGE_SENT}.${message.chatRoomId}`,
|
||||
message,
|
||||
)
|
||||
ctx.http.pubSub.publish(`${PubSubEvent.MESSAGE_SENT}.${message.chatRoomId}`, message)
|
||||
// publish to new message subscribers
|
||||
userIds.forEach((userId: string) => {
|
||||
ctx.http.pubSub.publish(
|
||||
`${PubSubEvent.NEW_MESSAGE}.${userId}`,
|
||||
message,
|
||||
)
|
||||
ctx.http.pubSub.publish(`${PubSubEvent.NEW_MESSAGE}.${userId}`, message)
|
||||
})
|
||||
return message
|
||||
},
|
||||
@@ -215,9 +198,7 @@ export class MessageSchema extends PothosSchema {
|
||||
const {
|
||||
websocket: { pubSub },
|
||||
} = ctx
|
||||
return pubSub.asyncIterableIterator([
|
||||
`${PubSubEvent.MESSAGE_SENT}.${args.chatRoomId}`,
|
||||
])
|
||||
return pubSub.asyncIterableIterator([`${PubSubEvent.MESSAGE_SENT}.${args.chatRoomId}`])
|
||||
},
|
||||
resolve: (payload: Message) => payload,
|
||||
}),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Module, Global } from '@nestjs/common'
|
||||
import { MinioService } from './minio.service'
|
||||
import { Global, Module } from '@nestjs/common'
|
||||
import { NestMinioModule } from 'nestjs-minio'
|
||||
import { MinioService } from './minio.service'
|
||||
@Global()
|
||||
@Module({
|
||||
imports: [
|
||||
|
||||
@@ -2,11 +2,11 @@ import { Inject, Injectable, Logger } from '@nestjs/common'
|
||||
import { ConfigService } from '@nestjs/config'
|
||||
// @ts-expect-error
|
||||
import { FileUpload } from 'graphql-upload/processRequest.mjs'
|
||||
import { Client, BucketItem } from 'minio'
|
||||
import { BucketItem, Client } from 'minio'
|
||||
import { MINIO_CONNECTION } from 'nestjs-minio'
|
||||
import Delta from 'quill-delta'
|
||||
import { DateTimeUtils } from 'src/common/utils/datetime.utils'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import Delta from 'quill-delta'
|
||||
@Injectable()
|
||||
export class MinioService {
|
||||
constructor(
|
||||
@@ -141,7 +141,11 @@ export class MinioService {
|
||||
// get the record url from minio by searching for the file starting with roomId and ending with .mp4 and returning the presigned url
|
||||
async getRoomRecordUrl(roomId: string) {
|
||||
return await new Promise<string | null>(async (resolve, reject) => {
|
||||
const stream = this.minioClient.listObjects(this.configService.get('BUCKET_NAME') ?? 'epess', `records/${roomId}`, true)
|
||||
const stream = this.minioClient.listObjects(
|
||||
this.configService.get('BUCKET_NAME') ?? 'epess',
|
||||
`records/${roomId}`,
|
||||
true,
|
||||
)
|
||||
const items: BucketItem[] = []
|
||||
|
||||
stream.on('data', (item) => {
|
||||
@@ -149,7 +153,15 @@ export class MinioService {
|
||||
})
|
||||
stream.on('end', async () => {
|
||||
const record = items.find((item) => item.name?.endsWith('.mp4'))
|
||||
resolve(record ? await this.minioClient.presignedUrl('GET', this.configService.get('BUCKET_NAME') ?? 'epess', record.name ?? '') : null)
|
||||
resolve(
|
||||
record
|
||||
? await this.minioClient.presignedUrl(
|
||||
'GET',
|
||||
this.configService.get('BUCKET_NAME') ?? 'epess',
|
||||
record.name ?? '',
|
||||
)
|
||||
: null,
|
||||
)
|
||||
})
|
||||
stream.on('error', (err) => {
|
||||
reject(err)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Module } from '@nestjs/common'
|
||||
import { NotificationService } from './notification.service'
|
||||
import { PubSubModule } from 'src/PubSub/pubsub.module'
|
||||
import { NotificationService } from './notification.service'
|
||||
@Module({
|
||||
imports: [PubSubModule],
|
||||
providers: [NotificationService],
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import { PubSubEvent } from 'src/common/pubsub/pubsub-event'
|
||||
import { PrismaService } from 'src/Prisma/prisma.service'
|
||||
import { PubSubService } from 'src/PubSub/pubsub.service'
|
||||
import { Logger } from '@nestjs/common'
|
||||
import { MessageContextType, MessageType } from '@prisma/client'
|
||||
import { PrismaService } from 'src/Prisma/prisma.service'
|
||||
import { PubSubService } from 'src/PubSub/pubsub.service'
|
||||
import { PubSubEvent } from 'src/common/pubsub/pubsub-event'
|
||||
@Injectable()
|
||||
export class NotificationService {
|
||||
constructor(
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { readFileSync } from 'fs'
|
||||
import { Injectable, Logger } from '@nestjs/common'
|
||||
import { OpenAI } from 'openai'
|
||||
import { zodResponseFormat } from 'openai/helpers/zod'
|
||||
import Delta from 'quill-delta'
|
||||
import { z } from 'zod'
|
||||
import { zodResponseFormat } from 'openai/helpers/zod'
|
||||
import { readFileSync } from 'fs'
|
||||
|
||||
const DELTA_INSTRUCTIONS = ''
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Module } from '@nestjs/common'
|
||||
import { OrderSchema } from './order.schema'
|
||||
import { PayosModule } from 'src/Payos/payos.module'
|
||||
import { OrderSchema } from './order.schema'
|
||||
@Module({
|
||||
imports: [PayosModule],
|
||||
providers: [OrderSchema],
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Inject, Injectable, Logger } from '@nestjs/common'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { Builder } from '../Graphql/graphql.builder'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
import { OrderStatus, ScheduleDateStatus, ScheduleStatus } from '@prisma/client'
|
||||
import { DateTimeUtils } from '../common/utils/datetime.utils'
|
||||
import { PayosService } from '../Payos/payos.service'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import _ from 'lodash'
|
||||
import { Builder } from '../Graphql/graphql.builder'
|
||||
import { PayosService } from '../Payos/payos.service'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
import { DateTimeUtils } from '../common/utils/datetime.utils'
|
||||
@Injectable()
|
||||
export class OrderSchema extends PothosSchema {
|
||||
constructor(
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
import { Inject, Injectable } from '@nestjs/common'
|
||||
import {
|
||||
Pothos,
|
||||
PothosRef,
|
||||
PothosSchema,
|
||||
SchemaBuilderToken,
|
||||
} from '@smatch-corp/nestjs-pothos'
|
||||
import { PaymentStatus } from '@prisma/client'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { Builder } from '../Graphql/graphql.builder'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
import { PaymentStatus } from '@prisma/client'
|
||||
|
||||
@Injectable()
|
||||
export class PaymentSchema extends PothosSchema {
|
||||
@@ -64,7 +59,7 @@ export class PaymentSchema extends PothosSchema {
|
||||
type: this.payment(),
|
||||
description: 'Retrieve a single payment by its unique identifier.',
|
||||
args: this.builder.generator.findUniqueArgs('Payment'),
|
||||
resolve: async (query, root, args, ctx, info) => {
|
||||
resolve: async (query, _root, args, _ctx, _info) => {
|
||||
return await this.prisma.payment.findUnique({
|
||||
...query,
|
||||
where: args.where,
|
||||
@@ -74,9 +69,8 @@ export class PaymentSchema extends PothosSchema {
|
||||
payments: t.prismaField({
|
||||
type: [this.payment()],
|
||||
args: this.builder.generator.findManyArgs('Payment'),
|
||||
description:
|
||||
'Retrieve a list of payments with optional filtering, ordering, and pagination.',
|
||||
resolve: async (query, root, args, ctx, info) => {
|
||||
description: 'Retrieve a list of payments with optional filtering, ordering, and pagination.',
|
||||
resolve: async (query, _root, args, _ctx, _info) => {
|
||||
return await this.prisma.payment.findMany({
|
||||
...query,
|
||||
where: args.filter ?? undefined,
|
||||
|
||||
@@ -1,16 +1,7 @@
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
Put,
|
||||
Delete,
|
||||
Param,
|
||||
Body,
|
||||
Headers,
|
||||
} from '@nestjs/common'
|
||||
import { PayosService } from './payos.service'
|
||||
import { ApiTags, ApiOperation } from '@nestjs/swagger'
|
||||
import { Body, Controller, Delete, Get, Headers, Param, Post, Put } from '@nestjs/common'
|
||||
import { ApiOperation, ApiTags } from '@nestjs/swagger'
|
||||
import { WebhookType } from '@payos/node/lib/type'
|
||||
import { PayosService } from './payos.service'
|
||||
|
||||
@ApiTags('Payos')
|
||||
@Controller('payos')
|
||||
@@ -34,6 +25,7 @@ export class PayosController {
|
||||
// test create payment url
|
||||
@Post('create-payment-url')
|
||||
@ApiOperation({ summary: 'Test create payment url' })
|
||||
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
||||
async createPaymentURL(@Body() body: any) {
|
||||
return this.payosService.createPaymentURL(body)
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { HttpModule } from '@nestjs/axios'
|
||||
import { Module } from '@nestjs/common'
|
||||
import PayOS from '@payos/node'
|
||||
import { PayosController } from './payos.controller'
|
||||
import { PayosService } from './payos.service'
|
||||
import { HttpModule } from '@nestjs/axios'
|
||||
import PayOS from '@payos/node'
|
||||
|
||||
@Module({
|
||||
imports: [HttpModule],
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import { Inject, Injectable, Logger } from '@nestjs/common'
|
||||
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
import PayOS from '@payos/node'
|
||||
import type {
|
||||
CancelPaymentLinkRequestType,
|
||||
CheckoutRequestType,
|
||||
CheckoutResponseDataType,
|
||||
WebhookType,
|
||||
WebhookDataType,
|
||||
CancelPaymentLinkRequestType,
|
||||
DataType,
|
||||
WebhookDataType,
|
||||
WebhookType,
|
||||
} from '@payos/node/lib/type'
|
||||
import {
|
||||
ChatRoomType,
|
||||
@@ -18,6 +17,7 @@ import {
|
||||
ScheduleDateStatus,
|
||||
ScheduleStatus,
|
||||
} from '@prisma/client'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
export type CreatePaymentBody = CheckoutRequestType
|
||||
export type CreatePaymentResponse = CheckoutResponseDataType
|
||||
@Injectable()
|
||||
@@ -47,8 +47,7 @@ export class PayosService {
|
||||
Logger.error(`Invalid checksum: ${JSON.stringify(data)}`)
|
||||
throw new Error('Invalid checksum')
|
||||
}
|
||||
const paymentStatus =
|
||||
paymentData.code === '00' ? PaymentStatus.PAID : PaymentStatus.CANCELLED
|
||||
const paymentStatus = paymentData.code === '00' ? PaymentStatus.PAID : PaymentStatus.CANCELLED
|
||||
/* ---------------------------- begin transaction --------------------------- */
|
||||
try {
|
||||
await this.prisma.$transaction(async (tx) => {
|
||||
@@ -59,10 +58,7 @@ export class PayosService {
|
||||
status: paymentStatus,
|
||||
},
|
||||
})
|
||||
const orderStatus =
|
||||
paymentStatus === PaymentStatus.PAID
|
||||
? OrderStatus.PAID
|
||||
: OrderStatus.FAILED
|
||||
const orderStatus = paymentStatus === PaymentStatus.PAID ? OrderStatus.PAID : OrderStatus.FAILED
|
||||
// update order status
|
||||
await tx.order.update({
|
||||
where: { id: payment.orderId },
|
||||
@@ -129,8 +125,7 @@ export class PayosService {
|
||||
/* --------------- send first message from mentor to customer --------------- */
|
||||
await tx.message.create({
|
||||
data: {
|
||||
content:
|
||||
'Xin chào, mình là hướng dẫn viên của bạn, hãy bắt đầu học ngay nhé!',
|
||||
content: 'Xin chào, mình là hướng dẫn viên của bạn, hãy bắt đầu học ngay nhé!',
|
||||
type: MessageType.TEXT,
|
||||
chatRoomId: chatRoom.id,
|
||||
senderId: mentorId,
|
||||
@@ -158,10 +153,7 @@ export class PayosService {
|
||||
return await this.payos.getPaymentLinkInformation(orderId)
|
||||
}
|
||||
|
||||
async cancelPaymentURL(
|
||||
orderId: string | number,
|
||||
cancellationReason?: string,
|
||||
) {
|
||||
async cancelPaymentURL(orderId: string | number, cancellationReason?: string) {
|
||||
return await this.payos.cancelPaymentLink(orderId, cancellationReason)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Inject, Injectable, Logger } from '@nestjs/common'
|
||||
import { PersonalMilestoneStatus } from '@prisma/client'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { Builder } from '../Graphql/graphql.builder'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
import { PersonalMilestoneStatus } from '@prisma/client'
|
||||
|
||||
@Injectable()
|
||||
export class PersonalMilestoneSchema extends PothosSchema {
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
import {
|
||||
INestApplication,
|
||||
Injectable,
|
||||
Logger,
|
||||
OnModuleInit,
|
||||
} from '@nestjs/common'
|
||||
import { INestApplication, Injectable, Logger, OnModuleInit } from '@nestjs/common'
|
||||
|
||||
import { PrismaClient } from '@prisma/client'
|
||||
|
||||
@@ -51,14 +46,10 @@ export class PrismaService extends PrismaClient implements OnModuleInit {
|
||||
return
|
||||
} catch (error) {
|
||||
if (attempt < maxRetry) {
|
||||
this.logger.warn(
|
||||
`Connection attempt ${attempt} failed. Retrying in ${retryDelay}ms...`,
|
||||
)
|
||||
this.logger.warn(`Connection attempt ${attempt} failed. Retrying in ${retryDelay}ms...`)
|
||||
await this.delay(retryDelay)
|
||||
} else {
|
||||
this.logger.error(
|
||||
`Failed to connect to the database after ${maxRetry} attempts.`,
|
||||
)
|
||||
this.logger.error(`Failed to connect to the database after ${maxRetry} attempts.`)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Global, Module } from '@nestjs/common'
|
||||
import { PubSubRedisOptions, RedisPubSub } from 'graphql-redis-subscriptions'
|
||||
import { PubSubService } from './pubsub.service'
|
||||
import { RedisPubSub, PubSubRedisOptions } from 'graphql-redis-subscriptions'
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Inject, Injectable } from '@nestjs/common'
|
||||
import { AnswerType } from '@prisma/client'
|
||||
import { QuestionType } from '@prisma/client'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { Builder } from '../Graphql/graphql.builder'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
import { AnswerType } from '@prisma/client'
|
||||
import { QuestionType } from '@prisma/client'
|
||||
|
||||
@Injectable()
|
||||
export class QuizSchema extends PothosSchema {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import { Redis } from 'ioredis'
|
||||
import { User } from '@prisma/client'
|
||||
import { Redis } from 'ioredis'
|
||||
|
||||
@Injectable()
|
||||
export class RedisService {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Inject, Injectable } from '@nestjs/common'
|
||||
import { OrderStatus, PaymentStatus, RefundTicketStatus, Role } from '@prisma/client'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { DateTimeUtils } from 'src/common/utils/datetime.utils'
|
||||
import { Builder } from '../Graphql/graphql.builder'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
import { OrderStatus, PaymentStatus, RefundTicketStatus, Role } from '@prisma/client'
|
||||
import { DateTimeUtils } from 'src/common/utils/datetime.utils'
|
||||
import * as banks from '../common/utils/banks.json'
|
||||
@Injectable()
|
||||
export class RefundTicketSchema extends PothosSchema {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Controller, Get, Post, Put, Delete, Param, Body } from '@nestjs/common'
|
||||
import { Body, Controller, Delete, Get, Param, Post, Put } from '@nestjs/common'
|
||||
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'
|
||||
import { RestfulService } from './restful.service'
|
||||
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger'
|
||||
|
||||
@ApiTags('Restful')
|
||||
@Controller('restful')
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Module } from '@nestjs/common'
|
||||
import { RestfulController } from './restful.controller'
|
||||
import { RestfulService } from './restful.service'
|
||||
import { ClerkModule } from '../Clerk/clerk.module'
|
||||
import { PayosModule } from '../Payos/payos.module'
|
||||
import { RestfulController } from './restful.controller'
|
||||
import { RestfulService } from './restful.service'
|
||||
|
||||
@Module({
|
||||
imports: [ClerkModule, PayosModule],
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Inject, Injectable, Logger } from '@nestjs/common'
|
||||
import { ResumeStatus, Role } from '@prisma/client'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { Builder } from '../Graphql/graphql.builder'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
import { MinioService } from '../Minio/minio.service'
|
||||
import { ResumeStatus, Role } from '@prisma/client'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
@Injectable()
|
||||
export class ResumeSchema extends PothosSchema {
|
||||
constructor(
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { Inject, Injectable, Logger } from '@nestjs/common'
|
||||
import { CenterStatus, ScheduleDateStatus, ScheduleStatus } from '@prisma/client'
|
||||
import { Role } from '@prisma/client'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { DateTimeUtils } from 'src/common/utils/datetime.utils'
|
||||
import { AppConfigService } from '../AppConfig/appconfig.service'
|
||||
import { Builder } from '../Graphql/graphql.builder'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
import { CenterStatus, ScheduleDateStatus, ScheduleStatus } from '@prisma/client'
|
||||
import { ScheduleService } from './schedule.service'
|
||||
import { AppConfigService } from '../AppConfig/appconfig.service'
|
||||
import { ScheduleConfigType } from './schedule'
|
||||
import { DateTimeUtils } from 'src/common/utils/datetime.utils'
|
||||
import { Role } from '@prisma/client'
|
||||
import { ScheduleService } from './schedule.service'
|
||||
@Injectable()
|
||||
export class ScheduleSchema extends PothosSchema {
|
||||
constructor(
|
||||
|
||||
@@ -3,12 +3,12 @@ import { DateTimeUtils } from '../common/utils/datetime.utils'
|
||||
import { Injectable, Logger } from '@nestjs/common'
|
||||
import { PrismaService } from 'src/Prisma/prisma.service'
|
||||
|
||||
import { AppConfigService } from 'src/AppConfig/appconfig.service'
|
||||
import { PreviewScheduleType, ScheduleConfigType, ScheduleConfigTypeForCenter, ScheduleSlotType } from './schedule.d'
|
||||
import { Config, Schedule, ScheduleDate } from '@prisma/client'
|
||||
import { DateTime, Settings, Zone } from 'luxon'
|
||||
import _ from 'lodash'
|
||||
import { DateTime, Settings, Zone } from 'luxon'
|
||||
import { AppConfigService } from 'src/AppConfig/appconfig.service'
|
||||
import { ScheduleDateInput } from './schedule'
|
||||
import { PreviewScheduleType, ScheduleConfigType, ScheduleConfigTypeForCenter, ScheduleSlotType } from './schedule.d'
|
||||
|
||||
@Injectable()
|
||||
export class ScheduleService {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Inject, Injectable, Logger } from '@nestjs/common'
|
||||
import { Message, MessageContextType, MessageType, Role, ServiceStatus } from '@prisma/client'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { Builder } from '../Graphql/graphql.builder'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
import { MinioService } from '../Minio/minio.service'
|
||||
import { Role, ServiceStatus, Message, MessageContextType, MessageType } from '@prisma/client'
|
||||
import { MailService } from '../Mail/mail.service'
|
||||
import { MinioService } from '../Minio/minio.service'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
import { PubSubEvent } from '../common/pubsub/pubsub-event'
|
||||
import { DateTimeUtils } from '../common/utils/datetime.utils'
|
||||
@Injectable()
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
import { Inject, Injectable } from '@nestjs/common'
|
||||
import {
|
||||
Pothos,
|
||||
PothosRef,
|
||||
PothosSchema,
|
||||
SchemaBuilderToken,
|
||||
} from '@smatch-corp/nestjs-pothos'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { Builder } from '../Graphql/graphql.builder'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
|
||||
@@ -58,8 +53,7 @@ export class ServiceAndCategorySchema extends PothosSchema {
|
||||
serviceAndCategories: t.prismaField({
|
||||
type: [this.serviceAndCategory()],
|
||||
args: this.builder.generator.findManyArgs('ServiceAndCategory'),
|
||||
description:
|
||||
'Retrieve a list of service and categories with optional filtering, ordering, and pagination.',
|
||||
description: 'Retrieve a list of service and categories with optional filtering, ordering, and pagination.',
|
||||
resolve: async (query, _root, args, _ctx, _info) => {
|
||||
return await this.prisma.serviceAndCategory.findMany({
|
||||
...query,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Inject, Injectable, Logger } from '@nestjs/common'
|
||||
import { OrderStatus, Role, ScheduleStatus } from '@prisma/client'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { Builder } from '../Graphql/graphql.builder'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
import { OrderStatus, Role, ScheduleStatus } from '@prisma/client'
|
||||
|
||||
@Injectable()
|
||||
export class ServiceFeedbackSchema extends PothosSchema {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Module, Global } from '@nestjs/common'
|
||||
import { UploadedFileSchema } from './uploadedfile.schema'
|
||||
import { Global, Module } from '@nestjs/common'
|
||||
import { MinioModule } from '../Minio/minio.module'
|
||||
import { UploadedFileSchema } from './uploadedfile.schema'
|
||||
@Global()
|
||||
@Module({
|
||||
imports: [MinioModule],
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
import { Inject, Injectable } from '@nestjs/common'
|
||||
import {
|
||||
Pothos,
|
||||
PothosRef,
|
||||
PothosSchema,
|
||||
SchemaBuilderToken,
|
||||
} from '@smatch-corp/nestjs-pothos'
|
||||
import { UploadedFileType } from '@prisma/client'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { MinioService } from 'src/Minio/minio.service'
|
||||
import { Builder } from '../Graphql/graphql.builder'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
import { MinioService } from 'src/Minio/minio.service'
|
||||
import { UploadedFileType } from '@prisma/client'
|
||||
@Injectable()
|
||||
export class UploadedFileSchema extends PothosSchema {
|
||||
constructor(
|
||||
@@ -45,11 +40,7 @@ export class UploadedFileSchema extends PothosSchema {
|
||||
nullable: true,
|
||||
description: 'The URL of the file.',
|
||||
resolve: async (file) => {
|
||||
return await this.minioService.updatePresignUrl(
|
||||
file.fileName,
|
||||
'files',
|
||||
file.fileUrl,
|
||||
)
|
||||
return await this.minioService.updatePresignUrl(file.fileName, 'files', file.fileUrl)
|
||||
},
|
||||
}),
|
||||
uploadedAt: t.expose('uploadedAt', {
|
||||
@@ -77,8 +68,7 @@ export class UploadedFileSchema extends PothosSchema {
|
||||
init(): void {
|
||||
this.builder.queryFields((t) => ({
|
||||
uploadedFile: t.prismaField({
|
||||
description:
|
||||
'Retrieve a single uploaded file by its unique identifier.',
|
||||
description: 'Retrieve a single uploaded file by its unique identifier.',
|
||||
type: this.uploadedFile(),
|
||||
args: this.builder.generator.findUniqueArgs('UploadedFile'),
|
||||
resolve: async (query, _root, args) => {
|
||||
@@ -89,10 +79,7 @@ export class UploadedFileSchema extends PothosSchema {
|
||||
if (!file) {
|
||||
throw new Error('File not found')
|
||||
}
|
||||
const fileUrl = await this.minioService.getFileUrl(
|
||||
file.fileName,
|
||||
'files',
|
||||
)
|
||||
const fileUrl = await this.minioService.getFileUrl(file.fileName, 'files')
|
||||
if (!fileUrl) {
|
||||
throw new Error('Cannot retrieve file url')
|
||||
}
|
||||
@@ -101,8 +88,7 @@ export class UploadedFileSchema extends PothosSchema {
|
||||
},
|
||||
}),
|
||||
uploadedFiles: t.prismaField({
|
||||
description:
|
||||
'Retrieve a list of uploaded files with optional filtering, ordering, and pagination.',
|
||||
description: 'Retrieve a list of uploaded files with optional filtering, ordering, and pagination.',
|
||||
type: [this.uploadedFile()],
|
||||
args: this.builder.generator.findManyArgs('UploadedFile'),
|
||||
resolve: async (query, _root, args) => {
|
||||
@@ -113,9 +99,7 @@ export class UploadedFileSchema extends PothosSchema {
|
||||
orderBy: args.orderBy ?? undefined,
|
||||
where: args.filter ?? undefined,
|
||||
})
|
||||
const fileUrls = await Promise.all(
|
||||
files.map((file) => this.minioService.getFileUrl(file.id, 'files')),
|
||||
)
|
||||
const fileUrls = await Promise.all(files.map((file) => this.minioService.getFileUrl(file.id, 'files')))
|
||||
return files.map((file, index) => ({
|
||||
...file,
|
||||
fileUrl: fileUrls[index] ?? '',
|
||||
@@ -152,8 +136,7 @@ export class UploadedFileSchema extends PothosSchema {
|
||||
if (!user) {
|
||||
throw new Error('User not found')
|
||||
}
|
||||
const { filename, mimetype, actualFileName } =
|
||||
await this.minioService.uploadFile(args.file, 'files')
|
||||
const { filename, mimetype, actualFileName } = await this.minioService.uploadFile(args.file, 'files')
|
||||
if (!mimetype) {
|
||||
throw new Error('File type not supported')
|
||||
}
|
||||
@@ -202,16 +185,10 @@ export class UploadedFileSchema extends PothosSchema {
|
||||
if (!user) {
|
||||
throw new Error('User not found')
|
||||
}
|
||||
const uploadedFiles = await Promise.all(
|
||||
args.files.map((file) =>
|
||||
this.minioService.uploadFile(file, 'files'),
|
||||
),
|
||||
)
|
||||
const uploadedFiles = await Promise.all(args.files.map((file) => this.minioService.uploadFile(file, 'files')))
|
||||
// get file urls
|
||||
const fileUrls = await Promise.all(
|
||||
uploadedFiles.map((file) =>
|
||||
this.minioService.getFileUrl(file.filename, 'files'),
|
||||
),
|
||||
uploadedFiles.map((file) => this.minioService.getFileUrl(file.filename, 'files')),
|
||||
)
|
||||
// map uploadedFiles to db
|
||||
const dbFiles = uploadedFiles.map((file, index) => ({
|
||||
@@ -224,8 +201,7 @@ export class UploadedFileSchema extends PothosSchema {
|
||||
uploadedAt: new Date(),
|
||||
}))
|
||||
// create files in db
|
||||
const createdFiles =
|
||||
await this.prisma.uploadedFile.createManyAndReturn({
|
||||
const createdFiles = await this.prisma.uploadedFile.createManyAndReturn({
|
||||
data: dbFiles,
|
||||
})
|
||||
return createdFiles
|
||||
@@ -261,8 +237,7 @@ export class UploadedFileSchema extends PothosSchema {
|
||||
}),
|
||||
|
||||
deleteUploadedFiles: t.prismaField({
|
||||
description:
|
||||
'Delete multiple uploaded files by their unique identifiers.',
|
||||
description: 'Delete multiple uploaded files by their unique identifiers.',
|
||||
type: [this.uploadedFile()],
|
||||
args: {
|
||||
ids: t.arg({
|
||||
@@ -285,11 +260,7 @@ export class UploadedFileSchema extends PothosSchema {
|
||||
},
|
||||
},
|
||||
})
|
||||
await Promise.all(
|
||||
files.map((file) =>
|
||||
this.minioService.deleteFile(file.fileName, 'files'),
|
||||
),
|
||||
)
|
||||
await Promise.all(files.map((file) => this.minioService.deleteFile(file.fileName, 'files')))
|
||||
return files
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Module } from '@nestjs/common'
|
||||
import { UserSchema } from './user.schema'
|
||||
import { MessageModule } from '../Message/message.module'
|
||||
import { ChatroomModule } from '../ChatRoom/chatroom.module'
|
||||
import { MessageModule } from '../Message/message.module'
|
||||
import { UserSchema } from './user.schema'
|
||||
@Module({
|
||||
imports: [MessageModule, ChatroomModule],
|
||||
providers: [UserSchema],
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { Inject, Injectable, Logger } from '@nestjs/common'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { Builder, SchemaContext } from '../Graphql/graphql.builder'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
import { clerkClient } from '@clerk/express'
|
||||
import { MailService } from '../Mail/mail.service'
|
||||
import { MessageSchema } from 'src/Message/message.schema'
|
||||
import { Inject, Injectable, Logger } from '@nestjs/common'
|
||||
import { ChatRoom, Message, MessageContextType, MessageType, Role } from '@prisma/client'
|
||||
import { PubSubEvent } from 'src/common/pubsub/pubsub-event'
|
||||
import { DateTimeUtils } from 'src/common/utils/datetime.utils'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { ChatroomSchema } from '../ChatRoom/chatroom.schema'
|
||||
import { Builder, SchemaContext } from '../Graphql/graphql.builder'
|
||||
import { MailService } from '../Mail/mail.service'
|
||||
import { MessageSchema } from '../Message/message.schema'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
import { PubSubEvent } from '../common/pubsub/pubsub-event'
|
||||
import { DateTimeUtils } from '../common/utils/datetime.utils'
|
||||
@Injectable()
|
||||
export class UserSchema extends PothosSchema {
|
||||
constructor(
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Inject, Injectable } from '@nestjs/common'
|
||||
import { Role } from '@prisma/client'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { MinioService } from 'src/Minio/minio.service'
|
||||
import { Builder } from '../Graphql/graphql.builder'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
import { MinioService } from 'src/Minio/minio.service'
|
||||
import { Role } from '@prisma/client'
|
||||
|
||||
@Injectable()
|
||||
export class WorkshopSchema extends PothosSchema {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Module, Global } from '@nestjs/common'
|
||||
import { Global, Module } from '@nestjs/common'
|
||||
import { WorkshopMeetingRoomSchema } from './workshopmeetingroom.schema'
|
||||
|
||||
@Module({
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Inject, Injectable } from '@nestjs/common'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { Builder } from '../Graphql/graphql.builder'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
import { LiveKitService } from '../LiveKit/livekit.service'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
@Injectable()
|
||||
export class WorkshopMeetingRoomSchema extends PothosSchema {
|
||||
constructor(
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
import { Inject, Injectable } from '@nestjs/common'
|
||||
import {
|
||||
Pothos,
|
||||
PothosRef,
|
||||
PothosSchema,
|
||||
SchemaBuilderToken,
|
||||
} from '@smatch-corp/nestjs-pothos'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { Builder } from '../Graphql/graphql.builder'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
|
||||
@@ -34,8 +29,7 @@ export class WorkshopOrganizationSchema extends PothosSchema {
|
||||
}),
|
||||
createdAt: t.expose('createdAt', {
|
||||
type: 'DateTime',
|
||||
description:
|
||||
'The date and time the workshop organization was created.',
|
||||
description: 'The date and time the workshop organization was created.',
|
||||
}),
|
||||
}),
|
||||
})
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Inject, Injectable } from '@nestjs/common'
|
||||
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { DateTimeUtils } from 'src/common/utils/datetime.utils'
|
||||
import { Builder } from '../Graphql/graphql.builder'
|
||||
import { PrismaService } from '../Prisma/prisma.service'
|
||||
import { DateTimeUtils } from 'src/common/utils/datetime.utils'
|
||||
|
||||
@Injectable()
|
||||
export class WorkshopSubscriptionSchema extends PothosSchema {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { ClerkModule } from './Clerk/clerk.module'
|
||||
import { Module } from '@nestjs/common'
|
||||
import { ConfigModule } from '@nestjs/config'
|
||||
import { ClerkModule } from './Clerk/clerk.module'
|
||||
import { CronModule } from './Cron/cron.module'
|
||||
import { GraphqlModule } from './Graphql/graphql.module'
|
||||
import { MailModule } from './Mail/mail.module'
|
||||
import { Module } from '@nestjs/common'
|
||||
import { RestfulModule } from './Restful/restful.module'
|
||||
import { CronModule } from './Cron/cron.module'
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import { Inject, Injectable } from '@nestjs/common'
|
||||
import { PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
|
||||
import { Builder } from '../../Graphql/graphql.builder'
|
||||
import {
|
||||
PothosRef,
|
||||
PothosSchema,
|
||||
SchemaBuilderToken,
|
||||
} from '@smatch-corp/nestjs-pothos'
|
||||
|
||||
@Injectable()
|
||||
export class CommonGraphqlError extends PothosSchema {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import _ from 'lodash'
|
||||
import { DateTime, Settings, HourNumbers, MinuteNumbers, SecondNumbers, DayNumbers, WeekdayNumbers } from 'luxon'
|
||||
import { DateTime, DayNumbers, HourNumbers, MinuteNumbers, SecondNumbers, Settings, WeekdayNumbers } from 'luxon'
|
||||
|
||||
Settings.defaultLocale = 'en-US'
|
||||
Settings.defaultZone = 'utc'
|
||||
|
||||
10
src/main.ts
10
src/main.ts
@@ -1,14 +1,14 @@
|
||||
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'
|
||||
|
||||
import { AppModule } from './app.module'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { clerkMiddleware } from '@clerk/express'
|
||||
import { Logger } from '@nestjs/common'
|
||||
import { NestFactory } from '@nestjs/core'
|
||||
import { clerkMiddleware } from '@clerk/express'
|
||||
import { json } from 'express'
|
||||
// @ts-expect-error
|
||||
import graphqlUploadExpress from 'graphql-upload/graphqlUploadExpress.mjs'
|
||||
import path from 'node:path'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { json } from 'express'
|
||||
import { AppModule } from './app.module'
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule, {})
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,5 +1,5 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing'
|
||||
import { INestApplication } from '@nestjs/common'
|
||||
import { Test, TestingModule } from '@nestjs/testing'
|
||||
import * as request from 'supertest'
|
||||
import { AppModule } from './../src/app.module'
|
||||
|
||||
@@ -16,9 +16,6 @@ describe('AppController (e2e)', () => {
|
||||
})
|
||||
|
||||
it('/ (GET)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/')
|
||||
.expect(200)
|
||||
.expect('Hello World!')
|
||||
return request(app.getHttpServer()).get('/').expect(200).expect('Hello World!')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"test",
|
||||
"dist",
|
||||
"**/*spec.ts",
|
||||
"epess-database",
|
||||
"codegen.ts",
|
||||
],
|
||||
"exclude": ["node_modules", "test", "dist", "**/*spec.ts", "epess-database", "codegen.ts"],
|
||||
"compilerOptions": {
|
||||
"rootDir": "./src",
|
||||
"allowJs": true
|
||||
|
||||
@@ -21,6 +21,6 @@
|
||||
"allowJs": true,
|
||||
"maxNodeModuleJsDepth": 10,
|
||||
"resolveJsonModule": true,
|
||||
"moduleResolution": "nodenext",
|
||||
"moduleResolution": "nodenext"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user