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:
2024-12-08 20:49:52 +07:00
parent 9e6d62e4be
commit 10e20092ab
82 changed files with 1697 additions and 2259 deletions

12
.vscode/launch.json vendored
View File

@@ -8,9 +8,7 @@
"name": "Attach by Process ID", "name": "Attach by Process ID",
"processId": "${command:PickProcess}", "processId": "${command:PickProcess}",
"request": "attach", "request": "attach",
"skipFiles": [ "skipFiles": ["<node_internals>/**"],
"<node_internals>/**"
],
"type": "node" "type": "node"
}, },
{ {
@@ -18,14 +16,10 @@
"request": "launch", "request": "launch",
"name": "Launch Program", "name": "Launch Program",
"runtimeExecutable": "C:\\Users\\AliensVN\\AppData\\Roaming\\fnm\\node-versions\\v22.6.0\\installation\\node.exe", "runtimeExecutable": "C:\\Users\\AliensVN\\AppData\\Roaming\\fnm\\node-versions\\v22.6.0\\installation\\node.exe",
"skipFiles": [ "skipFiles": ["<node_internals>/**"],
"<node_internals>/**"
],
"cwd": "${workspaceFolder}", "cwd": "${workspaceFolder}",
"program": "${file}", "program": "${file}",
"outFiles": [ "outFiles": ["${workspaceFolder}/**/*.js"]
"${workspaceFolder}/**/*.js"
]
} }
] ]
} }

View File

@@ -7,7 +7,7 @@
}, },
"files": { "files": {
"ignoreUnknown": false, "ignoreUnknown": false,
"ignore": ["dist"] "ignore": ["dist", "graphql.d.ts"]
}, },
"formatter": { "formatter": {
"enabled": true, "enabled": true,

View File

@@ -7,7 +7,6 @@
"license": "UNLICENSED", "license": "UNLICENSED",
"scripts": { "scripts": {
"build": "nest build", "build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start", "start": "nest start",
"start:dev": "nest start --watch", "start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch", "start:debug": "nest start --debug --watch",
@@ -20,8 +19,8 @@
"prisma:seed": "npx prisma db seed --schema=./epess-database/prisma/schema.prisma", "prisma:seed": "npx prisma db seed --schema=./epess-database/prisma/schema.prisma",
"prisma:format": "npx prisma format --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", "prisma:studio": "dotenv -e .env -- npx prisma studio --schema=./epess-database/prisma/schema.prisma",
"biome:check": "biome check", "biome:check": "biome check --write --unsafe",
"biome:fix": "biome fix --write", "biome:format": "biome format --write",
"test": "jest", "test": "jest",
"test:watch": "jest --watch", "test:watch": "jest --watch",
"test:cov": "jest --coverage", "test:cov": "jest --coverage",
@@ -138,19 +137,13 @@
"@css-inline/css-inline-linux-x64-musl": "^0.14.3" "@css-inline/css-inline-linux-x64-musl": "^0.14.3"
}, },
"jest": { "jest": {
"moduleFileExtensions": [ "moduleFileExtensions": ["js", "json", "ts"],
"js",
"json",
"ts"
],
"rootDir": "src", "rootDir": "src",
"testRegex": ".*\\.spec\\.ts$", "testRegex": ".*\\.spec\\.ts$",
"transform": { "transform": {
"^.+\\.(t|j)s$": "ts-jest" "^.+\\.(t|j)s$": "ts-jest"
}, },
"collectCoverageFrom": [ "collectCoverageFrom": ["**/*.(t|j)s"],
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage", "coverageDirectory": "../coverage",
"testEnvironment": "node" "testEnvironment": "node"
}, },

View File

@@ -1,5 +1,5 @@
import { AdminNoteSchema } from './adminnote.schema'
import { Module } from '@nestjs/common' import { Module } from '@nestjs/common'
import { AdminNoteSchema } from './adminnote.schema'
@Module({ @Module({
providers: [AdminNoteSchema], providers: [AdminNoteSchema],

View File

@@ -1,10 +1,5 @@
import { Inject, Injectable } from '@nestjs/common' import { Inject, Injectable } from '@nestjs/common'
import { import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
Pothos,
PothosRef,
PothosSchema,
SchemaBuilderToken,
} from '@smatch-corp/nestjs-pothos'
import { Builder } from '../Graphql/graphql.builder' import { Builder } from '../Graphql/graphql.builder'
import { PrismaService } from '../Prisma/prisma.service' 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.', description: 'The date and time the admin note was last updated.',
}), }),
centerId: t.exposeString('centerId', { centerId: t.exposeString('centerId', {
description: description: 'The ID of the center the admin note is associated with.',
'The ID of the center the admin note is associated with.',
}), }),
serviceId: t.exposeString('serviceId', { serviceId: t.exposeString('serviceId', {
description: description: 'The ID of the service the admin note is associated with.',
'The ID of the service the admin note is associated with.',
}), }),
mentorId: t.exposeString('mentorId', { mentorId: t.exposeString('mentorId', {
description: description: 'The ID of the mentor the admin note is associated with.',
'The ID of the mentor the admin note is associated with.',
}), }),
resumeId: t.exposeString('resumeId', { resumeId: t.exposeString('resumeId', {
description: description: 'The ID of the resume the admin note is associated with.',
'The ID of the resume the admin note is associated with.',
}), }),
mentor: t.relation('mentor', { mentor: t.relation('mentor', {
description: 'The mentor the admin note is associated with.', description: 'The mentor the admin note is associated with.',

View File

@@ -1,9 +1,9 @@
import { Module } from '@nestjs/common' 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 { CenterSchema } from 'src/Center/center.schema'
import { OrderSchema } from 'src/Order/order.schema' import { OrderSchema } from 'src/Order/order.schema'
import { PayosModule } from 'src/Payos/payos.module' import { PayosModule } from 'src/Payos/payos.module'
import { ServiceSchema } from 'src/Service/service.schema'
import { AnalyticSchema } from './analytic.schema'
@Module({ @Module({
imports: [PayosModule], imports: [PayosModule],

View File

@@ -1,12 +1,12 @@
import { Inject, Injectable } from '@nestjs/common' import { Inject, Injectable } from '@nestjs/common'
import { OrderStatus, Prisma, Role, ServiceStatus } from '@prisma/client' import { OrderStatus, Prisma, Role, ServiceStatus } from '@prisma/client'
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos' 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 { Builder } from 'src/Graphql/graphql.builder'
import { OrderSchema } from 'src/Order/order.schema'
import { PrismaService } from 'src/Prisma/prisma.service' import { PrismaService } from 'src/Prisma/prisma.service'
import { ServiceSchema } from 'src/Service/service.schema' import { ServiceSchema } from 'src/Service/service.schema'
import { CenterSchema } from 'src/Center/center.schema' import { DateTimeUtils } from 'src/common/utils/datetime.utils'
import { OrderSchema } from 'src/Order/order.schema'
@Injectable() @Injectable()
export class AnalyticSchema extends PothosSchema { export class AnalyticSchema extends PothosSchema {
constructor( constructor(

View File

@@ -1,12 +1,8 @@
import { Inject, Injectable } from '@nestjs/common' import { Inject, Injectable } from '@nestjs/common'
import { import { PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
PothosRef,
PothosSchema,
SchemaBuilderToken,
} from '@smatch-corp/nestjs-pothos'
import { Builder } from 'src/Graphql/graphql.builder' import { Builder } from 'src/Graphql/graphql.builder'
import { AppConfigService } from './appconfig.service'
import { PrismaService } from 'src/Prisma/prisma.service' import { PrismaService } from 'src/Prisma/prisma.service'
import { AppConfigService } from './appconfig.service'
@Injectable() @Injectable()
export class AppConfigSchema extends PothosSchema { export class AppConfigSchema extends PothosSchema {

View File

@@ -1,9 +1,9 @@
import { Injectable, OnModuleInit } from '@nestjs/common' import { Injectable, OnModuleInit } from '@nestjs/common'
import { PrismaService } from 'src/Prisma/prisma.service'
import { ConfigConstants } from './appconfig.constant'
import { Config } from '@prisma/client' import { Config } from '@prisma/client'
import { PrismaService } from 'src/Prisma/prisma.service'
import { StringUtils } from 'src/common/utils/string.utils' import { StringUtils } from 'src/common/utils/string.utils'
import { ConfigConstants } from './appconfig.constant'
@Injectable() @Injectable()
export class AppConfigService implements OnModuleInit { export class AppConfigService implements OnModuleInit {

View File

@@ -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 { 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 { 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() @Injectable()
export class CenterSchema extends PothosSchema { export class CenterSchema extends PothosSchema {

View File

@@ -1,6 +1,6 @@
import { CenterMentorSchema } from './centermentor.schema'
import { Module } from '@nestjs/common' import { Module } from '@nestjs/common'
import { UserModule } from 'src/User/user.module' import { UserModule } from 'src/User/user.module'
import { CenterMentorSchema } from './centermentor.schema'
@Module({ @Module({
imports: [UserModule], imports: [UserModule],

View File

@@ -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 { clerkClient } from '@clerk/express'
import { RedisService } from 'src/Redis/redis.service' import { Inject, Injectable } from '@nestjs/common'
import { Role } from '@prisma/client' 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() @Injectable()
export class CenterMentorSchema extends PothosSchema { export class CenterMentorSchema extends PothosSchema {
constructor( constructor(

View File

@@ -1,13 +1,8 @@
import { Inject, Injectable } from '@nestjs/common' import { Inject, Injectable } from '@nestjs/common'
import { import { ChatRoomType } from '@prisma/client'
Pothos, import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
PothosRef,
PothosSchema,
SchemaBuilderToken,
} from '@smatch-corp/nestjs-pothos'
import { Builder } from '../Graphql/graphql.builder' import { Builder } from '../Graphql/graphql.builder'
import { PrismaService } from '../Prisma/prisma.service' import { PrismaService } from '../Prisma/prisma.service'
import { ChatRoomType } from '@prisma/client'
@Injectable() @Injectable()
export class ChatroomSchema extends PothosSchema { export class ChatroomSchema extends PothosSchema {
@@ -86,8 +81,7 @@ export class ChatroomSchema extends PothosSchema {
chatRooms: t.prismaField({ chatRooms: t.prismaField({
type: [this.chatRoom()], type: [this.chatRoom()],
description: description: 'Retrieve a list of chat rooms with optional filtering, ordering, and pagination.',
'Retrieve a list of chat rooms with optional filtering, ordering, and pagination.',
args: this.builder.generator.findManyArgs('ChatRoom'), args: this.builder.generator.findManyArgs('ChatRoom'),
resolve: async (query, _root, args, _ctx, _info) => { resolve: async (query, _root, args, _ctx, _info) => {
return await this.prisma.chatRoom.findMany({ return await this.prisma.chatRoom.findMany({

View File

@@ -1,12 +1,6 @@
// clerk-auth.guard.ts
import {
Injectable,
CanActivate,
ExecutionContext,
Inject,
UnauthorizedException,
} from '@nestjs/common'
import Clerk from '@clerk/express' import Clerk from '@clerk/express'
// clerk-auth.guard.ts
import { CanActivate, ExecutionContext, Inject, Injectable, UnauthorizedException } from '@nestjs/common'
import { GqlExecutionContext } from '@nestjs/graphql' import { GqlExecutionContext } from '@nestjs/graphql'
@Injectable() @Injectable()
@@ -44,9 +38,7 @@ export class ClerkAuthGuard implements CanActivate {
return true return true
} catch (error: unknown) { } catch (error: unknown) {
throw new UnauthorizedException( throw new UnauthorizedException(error instanceof Error ? error.message : 'Unknown error')
error instanceof Error ? error.message : 'Unknown error',
)
} }
} }
} }

View File

@@ -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 { ClerkService } from './clerk.service'
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger'
@ApiTags('Clerk') @ApiTags('Clerk')
@Controller('clerk') @Controller('clerk')
export class ClerkController { export class ClerkController {
@@ -9,6 +9,7 @@ export class ClerkController {
@Post('webhook') @Post('webhook')
@ApiOperation({ summary: 'Clerk Webhook' }) @ApiOperation({ summary: 'Clerk Webhook' })
@ApiResponse({ status: 200, description: 'Webhook created successfully' }) @ApiResponse({ status: 200, description: 'Webhook created successfully' })
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
webhook(@Body() body: any) { webhook(@Body() body: any) {
return this.clerkService.webhook(body) return this.clerkService.webhook(body)
} }

View File

@@ -1,7 +1,7 @@
import { Module, Global } from '@nestjs/common'
import Clerk from '@clerk/express' import Clerk from '@clerk/express'
import { ClerkService } from './clerk.service' import { Global, Module } from '@nestjs/common'
import ClerkController from './clerk.controller' import ClerkController from './clerk.controller'
import { ClerkService } from './clerk.service'
@Global() @Global()
@Module({ @Module({
providers: [ providers: [

View File

@@ -1,7 +1,7 @@
import { Injectable, Logger } from '@nestjs/common' import { Injectable, Logger } from '@nestjs/common'
import { WebhookEventType, clerkClient } from '@clerk/express'
import { PrismaService } from '../Prisma/prisma.service' import { PrismaService } from '../Prisma/prisma.service'
import { clerkClient, WebhookEventType } from '@clerk/express'
import { RedisService } from '../Redis/redis.service' import { RedisService } from '../Redis/redis.service'
export interface ClerkResponse {} export interface ClerkResponse {}
@Injectable() @Injectable()
@@ -10,6 +10,7 @@ export class ClerkService {
private readonly prisma: PrismaService, private readonly prisma: PrismaService,
private readonly redis: RedisService, private readonly redis: RedisService,
) {} ) {}
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
async webhook(body: any) { async webhook(body: any) {
// get the event type // get the event type
const eventType = body.type const eventType = body.type
@@ -18,6 +19,7 @@ export class ClerkService {
return { message: `Webhook received: ${eventType}` } return { message: `Webhook received: ${eventType}` }
} }
// dispatch the event // dispatch the event
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
async dispatchEvent(eventType: WebhookEventType, data: any) { async dispatchEvent(eventType: WebhookEventType, data: any) {
// event types: // event types:
// user.created // user.created
@@ -55,10 +57,14 @@ export class ClerkService {
this.eventEmailCreated(data) this.eventEmailCreated(data)
} }
} }
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
async eventUserCreated(data: any) { async eventUserCreated(data: any) {
const primary_email_address_id = data.primary_email_address_id 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 // 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) { if (!primary_email_address) {
primary_email_address = '' primary_email_address = ''
} }
@@ -87,6 +93,7 @@ export class ClerkService {
} }
} }
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
async eventUserUpdated(data: any) { async eventUserUpdated(data: any) {
const user_id = data.id const user_id = data.id
const name = `${data.first_name} ${data.last_name}` 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) { async eventSessionCreated(data: any) {
// check if user exists in database or create user // check if user exists in database or create user
const user = await this.prisma.user.findUnique({ const user = await this.prisma.user.findUnique({
@@ -120,24 +128,28 @@ export class ClerkService {
// to do: get session info // to do: get session info
} }
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
async eventSessionRevoked(data: any) { async eventSessionRevoked(data: any) {
Logger.log(data, 'ClerkService') Logger.log(data, 'ClerkService')
// invalidate session from redis // invalidate session from redis
await this.redis.del(`session:${data.session_id}`) await this.redis.del(`session:${data.session_id}`)
} }
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
async eventSessionRemoved(data: any) { async eventSessionRemoved(data: any) {
Logger.log(data, 'ClerkService') Logger.log(data, 'ClerkService')
// invalidate session from redis // invalidate session from redis
await this.redis.del(`session:${data.session_id}`) await this.redis.del(`session:${data.session_id}`)
} }
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
async eventSessionEnded(data: any) { async eventSessionEnded(data: any) {
Logger.log(data, 'ClerkService') Logger.log(data, 'ClerkService')
// invalidate session from redis // invalidate session from redis
await this.redis.del(`session:${data.session_id}`) await this.redis.del(`session:${data.session_id}`)
} }
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
async eventEmailCreated(data: any) { async eventEmailCreated(data: any) {
Logger.log(data, 'ClerkService') Logger.log(data, 'ClerkService')
} }

View File

@@ -1,8 +1,8 @@
import { Module } from '@nestjs/common' import { Module } from '@nestjs/common'
import { CollaborationSessionSchema } from './collaborationsession.schema'
import { LiveKitModule } from 'src/LiveKit/livekit.module' import { LiveKitModule } from 'src/LiveKit/livekit.module'
import { LiveKitService } from 'src/LiveKit/livekit.service'
import { LiveKitRoomService } from 'src/LiveKit/livekit.room.service' import { LiveKitRoomService } from 'src/LiveKit/livekit.room.service'
import { LiveKitService } from 'src/LiveKit/livekit.service'
import { CollaborationSessionSchema } from './collaborationsession.schema'
@Module({ @Module({
imports: [LiveKitModule], imports: [LiveKitModule],

View File

@@ -1,12 +1,12 @@
import { Inject, Injectable, Logger } from '@nestjs/common' 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 { 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 { 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 { PrismaService } from 'src/Prisma/prisma.service'
import { DateTimeUtils } from 'src/common/utils/datetime.utils' import { DateTimeUtils } from 'src/common/utils/datetime.utils'
import { LiveKitService } from 'src/LiveKit/livekit.service'
import { LiveKitRoomService } from 'src/LiveKit/livekit.room.service'
@Injectable() @Injectable()
export class CollaborationSessionSchema extends PothosSchema { export class CollaborationSessionSchema extends PothosSchema {
constructor( constructor(
@@ -283,9 +283,7 @@ export class CollaborationSessionSchema extends PothosSchema {
}, },
}) })
if (!collaborationSession) throw new Error('Collaboration session not found') if (!collaborationSession) throw new Error('Collaboration session not found')
return ctx.websocket.pubSub.asyncIterableIterator( return ctx.websocket.pubSub.asyncIterableIterator(`collaborationSessionUpdated:${collaborationSession.id}`)
`collaborationSessionUpdated:${collaborationSession.id}`,
)
}, },
resolve: async (payload: CollaborationSession) => payload, resolve: async (payload: CollaborationSession) => payload,
}), }),

View File

@@ -1,8 +1,8 @@
import { Module } from '@nestjs/common' import { Module } from '@nestjs/common'
import { ScheduleModule } from '@nestjs/schedule' 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 { NotificationModule } from 'src/Notification/notification.module'
import { PubSubModule } from 'src/PubSub/pubsub.module'
import { CronService } from './cron.service'
@Module({ @Module({
imports: [ScheduleModule.forRoot(), NotificationModule, PubSubModule], imports: [ScheduleModule.forRoot(), NotificationModule, PubSubModule],
providers: [CronService], providers: [CronService],

View File

@@ -2,9 +2,9 @@ import { Injectable, Logger } from '@nestjs/common'
import { Cron } from '@nestjs/schedule' import { Cron } from '@nestjs/schedule'
import { CronExpression } from '@nestjs/schedule' import { CronExpression } from '@nestjs/schedule'
import { OrderStatus, PaymentStatus, ScheduleDateStatus, ScheduleStatus, ServiceStatus } from '@prisma/client' 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 { NotificationService } from 'src/Notification/notification.service'
import { PrismaService } from 'src/Prisma/prisma.service' import { PrismaService } from 'src/Prisma/prisma.service'
import { DateTimeUtils } from 'src/common/utils/datetime.utils'
@Injectable() @Injectable()
export class CronService { export class CronService {

View File

@@ -1,7 +1,7 @@
import { Module } from '@nestjs/common' import { Module } from '@nestjs/common'
import { DocumentService } from './document.service'
import { DocumentSchema } from './document.schema'
import { OpenaiModule } from 'src/OpenAI/openai.module' import { OpenaiModule } from 'src/OpenAI/openai.module'
import { DocumentSchema } from './document.schema'
import { DocumentService } from './document.service'
@Module({ @Module({
imports: [OpenaiModule], imports: [OpenaiModule],
providers: [DocumentService, DocumentSchema], providers: [DocumentService, DocumentSchema],

View File

@@ -1,12 +1,12 @@
import { Inject, Injectable, Logger } from '@nestjs/common' import { Inject, Injectable, Logger } from '@nestjs/common'
import { Document } from '@prisma/client'
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos' 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 { Builder, SchemaContext } from '../Graphql/graphql.builder'
import { PrismaService } from '../Prisma/prisma.service' import { PrismaService } from '../Prisma/prisma.service'
import { DocumentEvent } from './document.event' import { DocumentEvent } from './document.event'
import { Document } from '@prisma/client'
import { DocumentDelta } from './document.type' import { DocumentDelta } from './document.type'
import Delta from 'quill-delta'
import { MinioService } from 'src/Minio/minio.service'
@Injectable() @Injectable()
export class DocumentSchema extends PothosSchema { export class DocumentSchema extends PothosSchema {
constructor( constructor(

View File

@@ -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 Delta, { Op } from 'quill-delta'
import { PrismaService } from 'src/Prisma/prisma.service'
import { MinioService } from '../Minio/minio.service' import { MinioService } from '../Minio/minio.service'
import { DocumentDelta } from './document.type' import { DocumentDelta } from './document.type'
import { Logger } from '@nestjs/common'
import { PrismaService } from 'src/Prisma/prisma.service'
@Injectable() @Injectable()
export class DocumentService { export class DocumentService {
constructor( constructor(

View File

@@ -1,29 +1,29 @@
import { JSONObjectResolver } from 'graphql-scalars' import { Injectable, Logger } from '@nestjs/common'
import PrismaPlugin, { PothosPrismaDatamodel, PrismaClient } from '@pothos/plugin-prisma' import SchemaBuilder from '@pothos/core'
import { Request, Response } from 'express'
import SmartSubscriptionPlugin, { subscribeOptionsFromIterator } from '@pothos/plugin-smart-subscriptions'
import ZodPlugin from '@pothos/plugin-zod'
import AuthzPlugin from '@pothos/plugin-authz' import AuthzPlugin from '@pothos/plugin-authz'
import ErrorsPlugin from '@pothos/plugin-errors' import ErrorsPlugin from '@pothos/plugin-errors'
// @ts-expect-error import PrismaPlugin, { PothosPrismaDatamodel, PrismaClient } from '@pothos/plugin-prisma'
import type { FileUpload } from 'graphql-upload/processRequest.mjs' 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 // @ts-expect-error
import GraphQLUpload from 'graphql-upload/GraphQLUpload.mjs' import GraphQLUpload from 'graphql-upload/GraphQLUpload.mjs'
import { Injectable, Logger } from '@nestjs/common' // @ts-expect-error
import { PrismaCrudGenerator } from './graphql.generator' import type { FileUpload } from 'graphql-upload/processRequest.mjs'
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'
import { DateTime } from 'luxon' 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 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 = export type SchemaContext =
| { | {

View File

@@ -1,52 +1,52 @@
import { Global, Logger, Module } from '@nestjs/common' import { Global, Logger, Module } from '@nestjs/common'
import { AdminNoteModule } from '../AdminNote/adminnote.module'
import { ApolloDriverConfig } from '@nestjs/apollo' 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 { ConfigModule } from '@nestjs/config'
import { GraphQLModule } from '@nestjs/graphql' 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 { ManagedServiceModule } from '../ManagedService/managedservice.module'
import { MeetingRoomModule } from '../MeetingRoom/meetingroom.module'
import { MessageModule } from '../Message/message.module' import { MessageModule } from '../Message/message.module'
import { OrderModule } from '../Order/order.module' import { OrderModule } from '../Order/order.module'
import { PaymentModule } from '../Payment/payment.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 { PrismaModule } from '../Prisma/prisma.module'
import { PrismaService } from '../Prisma/prisma.service' 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 { RedisModule } from '../Redis/redis.module'
import { RedisService } from '../Redis/redis.service' import { RedisService } from '../Redis/redis.service'
import { RefundTicketModule } from '../RefundTicket/refundticket.module' import { RefundTicketModule } from '../RefundTicket/refundticket.module'
import { Request } from 'express'
import { ResumeModule } from '../Resume/resume.module' import { ResumeModule } from '../Resume/resume.module'
import { ScheduleModule } from '../Schedule/schedule.module' import { ScheduleModule } from '../Schedule/schedule.module'
import { ServiceModule } from '../Service/service.module'
import { ServiceAndCategoryModule } from '../ServiceAndCategory/serviceandcategory.module' import { ServiceAndCategoryModule } from '../ServiceAndCategory/serviceandcategory.module'
import { ServiceFeedbackModule } from '../ServiceFeedback/servicefeedback.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 { UploadedFileModule } from '../UploadedFile/uploadedfile.module'
import { UserModule } from '../User/user.module' import { UserModule } from '../User/user.module'
import { WorkshopMeetingRoomModule } from '../WorkshopMeetingRoom/workshopmeetingroom.module'
import { WorkshopModule } from '../Workshop/workshop.module' import { WorkshopModule } from '../Workshop/workshop.module'
import { WorkshopMeetingRoomModule } from '../WorkshopMeetingRoom/workshopmeetingroom.module'
import { WorkshopOrganizationModule } from '../WorkshopOrganization/workshoporganization.module' import { WorkshopOrganizationModule } from '../WorkshopOrganization/workshoporganization.module'
import { WorkshopSubscriptionModule } from '../WorkshopSubscription/workshopsubscription.module' import { WorkshopSubscriptionModule } from '../WorkshopSubscription/workshopsubscription.module'
import { initContextCache } from '@pothos/core' import { CommonModule } from '../common/common.module'
import { RedisPubSub } from 'graphql-redis-subscriptions' import { Builder } from './graphql.builder'
import { DocumentModule } from '../Document/document.module' import { PrismaCrudGenerator } from './graphql.generator'
import { Context } from 'graphql-ws' import { GraphqlService } from './graphql.service'
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'
@Global() @Global()
@Module({ @Module({

View File

@@ -1,8 +1,8 @@
import { Inject, Injectable, Logger, UnauthorizedException } from '@nestjs/common' import { Inject, Injectable, Logger, UnauthorizedException } from '@nestjs/common'
import { PrismaService } from '../Prisma/prisma.service'
import { Request } from 'express'
import { clerkClient } from '@clerk/express' import { clerkClient } from '@clerk/express'
import { Request } from 'express'
import { PrismaService } from '../Prisma/prisma.service'
import { RedisService } from '../Redis/redis.service' import { RedisService } from '../Redis/redis.service'

File diff suppressed because it is too large Load Diff

View File

@@ -2,9 +2,9 @@ import { Injectable } from '@nestjs/common'
import { import {
EgressClient, EgressClient,
EncodedFileOutput, EncodedFileOutput,
StreamOutput,
EncodedFileType, EncodedFileType,
EncodingOptionsPreset, EncodingOptionsPreset,
StreamOutput,
// @ts-expect-error // @ts-expect-error
} from 'livekit-server-sdk' } from 'livekit-server-sdk'

View File

@@ -1,7 +1,7 @@
import { Module, Global } from '@nestjs/common' import { Global, Module } from '@nestjs/common'
import { LiveKitService } from './livekit.service'
import { LiveKitRoomService } from './livekit.room.service'
import { LiveKitEgressService } from './livekit.egress.service' import { LiveKitEgressService } from './livekit.egress.service'
import { LiveKitRoomService } from './livekit.room.service'
import { LiveKitService } from './livekit.service'
@Global() @Global()
@Module({ @Module({
providers: [LiveKitService, LiveKitRoomService, LiveKitEgressService], providers: [LiveKitService, LiveKitRoomService, LiveKitEgressService],

View File

@@ -1,18 +1,18 @@
import { Injectable } from '@nestjs/common' import { Injectable } from '@nestjs/common'
import { import {
Room,
RoomServiceClient,
RoomEgress,
AutoTrackEgress,
AutoParticipantEgress, AutoParticipantEgress,
EncodedFileType, AutoTrackEgress,
EncodedFileOutput, EncodedFileOutput,
RoomCompositeEgressRequest, EncodedFileType,
EncodingOptionsPreset, EncodingOptionsPreset,
Room,
RoomCompositeEgressRequest,
RoomEgress,
RoomServiceClient,
// @ts-expect-error // @ts-expect-error
} from 'livekit-server-sdk' } from 'livekit-server-sdk'
import { LiveKitEgressService } from './livekit.egress.service'
import { DateTimeUtils } from 'src/common/utils/datetime.utils' import { DateTimeUtils } from 'src/common/utils/datetime.utils'
import { LiveKitEgressService } from './livekit.egress.service'
@Injectable() @Injectable()
export class LiveKitRoomService { export class LiveKitRoomService {

View File

@@ -1,7 +1,7 @@
import { User } from '@prisma/client'
import { Injectable, Logger } from '@nestjs/common' import { Injectable, Logger } from '@nestjs/common'
import { User } from '@prisma/client'
// @ts-expect-error // @ts-expect-error
import { RoomServiceClient, AccessToken } from 'livekit-server-sdk' import { AccessToken, RoomServiceClient } from 'livekit-server-sdk'
@Injectable() @Injectable()
export class LiveKitService { export class LiveKitService {

View File

@@ -2,10 +2,10 @@ import * as path from 'path'
import { Global, Module } from '@nestjs/common' import { Global, Module } from '@nestjs/common'
import { MailService } from './mail.service'
import { MailerModule } from '@nestjs-modules/mailer' import { MailerModule } from '@nestjs-modules/mailer'
import { OpenaiModule } from '../OpenAI/openai.module'
import { PugAdapter } from '@nestjs-modules/mailer/dist/adapters/pug.adapter' import { PugAdapter } from '@nestjs-modules/mailer/dist/adapters/pug.adapter'
import { OpenaiModule } from '../OpenAI/openai.module'
import { MailService } from './mail.service'
@Global() @Global()
@Module({ @Module({

View File

@@ -1,8 +1,8 @@
import { Injectable, Logger } from '@nestjs/common' import { Injectable, Logger } from '@nestjs/common'
import { MailerService } from '@nestjs-modules/mailer' import { MailerService } from '@nestjs-modules/mailer'
import { OpenaiService } from '../OpenAI/openai.service'
import { User } from '@prisma/client' import { User } from '@prisma/client'
import { OpenaiService } from '../OpenAI/openai.service'
@Injectable() @Injectable()
export class MailService { export class MailService {

View File

@@ -1,10 +1,5 @@
import { Inject, Injectable } from '@nestjs/common' import { Inject, Injectable } from '@nestjs/common'
import { import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
Pothos,
PothosRef,
PothosSchema,
SchemaBuilderToken,
} from '@smatch-corp/nestjs-pothos'
import { Builder } from '../Graphql/graphql.builder' import { Builder } from '../Graphql/graphql.builder'
import { PrismaService } from '../Prisma/prisma.service' import { PrismaService } from '../Prisma/prisma.service'

View File

@@ -1,6 +1,6 @@
import { Module } from '@nestjs/common' import { Module } from '@nestjs/common'
import { MeetingRoomSchema } from './meetingroom.schema'
import { LiveKitModule } from 'src/LiveKit/livekit.module' import { LiveKitModule } from 'src/LiveKit/livekit.module'
import { MeetingRoomSchema } from './meetingroom.schema'
@Module({ @Module({
imports: [LiveKitModule], imports: [LiveKitModule],

View File

@@ -1,9 +1,9 @@
import { Inject, Injectable, Logger } from '@nestjs/common' import { Inject, Injectable, Logger } 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, SchemaContext } from 'src/Graphql/graphql.builder' import { Builder, SchemaContext } from 'src/Graphql/graphql.builder'
import { PrismaService } from 'src/Prisma/prisma.service'
import { LiveKitService } from 'src/LiveKit/livekit.service' import { LiveKitService } from 'src/LiveKit/livekit.service'
import { MinioService } from 'src/Minio/minio.service' import { MinioService } from 'src/Minio/minio.service'
import { PrismaService } from 'src/Prisma/prisma.service'
@Injectable() @Injectable()
export class MeetingRoomSchema extends PothosSchema { export class MeetingRoomSchema extends PothosSchema {
constructor( constructor(

View File

@@ -1,20 +1,10 @@
import { Inject, Injectable, Logger } from '@nestjs/common' import { Inject, Injectable, Logger } from '@nestjs/common'
import { import { ChatRoomType, Message, MessageContextType, MessageType } from '@prisma/client'
Pothos, import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
PothosRef,
PothosSchema,
SchemaBuilderToken,
} from '@smatch-corp/nestjs-pothos'
import { Builder, SchemaContext } from '../Graphql/graphql.builder' import { Builder, SchemaContext } from '../Graphql/graphql.builder'
import { PrismaService } from '../Prisma/prisma.service' 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 { PubSubEvent } from '../common/pubsub/pubsub-event'
import { DateTimeUtils } from '../common/utils/datetime.utils'
@Injectable() @Injectable()
export class MessageSchema extends PothosSchema { export class MessageSchema extends PothosSchema {
@@ -85,8 +75,7 @@ export class MessageSchema extends PothosSchema {
}), }),
messages: t.prismaField({ messages: t.prismaField({
type: [this.message()], type: [this.message()],
description: description: 'Retrieve a list of messages with optional filtering, ordering, and pagination.',
'Retrieve a list of messages with optional filtering, ordering, and pagination.',
args: this.builder.generator.findManyArgs('Message'), args: this.builder.generator.findManyArgs('Message'),
resolve: async (query, _root, args) => { resolve: async (query, _root, args) => {
return await this.prisma.message.findMany({ return await this.prisma.message.findMany({
@@ -184,16 +173,10 @@ export class MessageSchema extends PothosSchema {
}) })
return message return message
}) })
ctx.http.pubSub.publish( ctx.http.pubSub.publish(`${PubSubEvent.MESSAGE_SENT}.${message.chatRoomId}`, message)
`${PubSubEvent.MESSAGE_SENT}.${message.chatRoomId}`,
message,
)
// publish to new message subscribers // publish to new message subscribers
userIds.forEach((userId: string) => { userIds.forEach((userId: string) => {
ctx.http.pubSub.publish( ctx.http.pubSub.publish(`${PubSubEvent.NEW_MESSAGE}.${userId}`, message)
`${PubSubEvent.NEW_MESSAGE}.${userId}`,
message,
)
}) })
return message return message
}, },
@@ -215,9 +198,7 @@ export class MessageSchema extends PothosSchema {
const { const {
websocket: { pubSub }, websocket: { pubSub },
} = ctx } = ctx
return pubSub.asyncIterableIterator([ return pubSub.asyncIterableIterator([`${PubSubEvent.MESSAGE_SENT}.${args.chatRoomId}`])
`${PubSubEvent.MESSAGE_SENT}.${args.chatRoomId}`,
])
}, },
resolve: (payload: Message) => payload, resolve: (payload: Message) => payload,
}), }),

View File

@@ -1,6 +1,6 @@
import { Module, Global } from '@nestjs/common' import { Global, Module } from '@nestjs/common'
import { MinioService } from './minio.service'
import { NestMinioModule } from 'nestjs-minio' import { NestMinioModule } from 'nestjs-minio'
import { MinioService } from './minio.service'
@Global() @Global()
@Module({ @Module({
imports: [ imports: [

View File

@@ -2,11 +2,11 @@ import { Inject, Injectable, Logger } from '@nestjs/common'
import { ConfigService } from '@nestjs/config' import { ConfigService } from '@nestjs/config'
// @ts-expect-error // @ts-expect-error
import { FileUpload } from 'graphql-upload/processRequest.mjs' import { FileUpload } from 'graphql-upload/processRequest.mjs'
import { Client, BucketItem } from 'minio' import { BucketItem, Client } from 'minio'
import { MINIO_CONNECTION } from 'nestjs-minio' import { MINIO_CONNECTION } from 'nestjs-minio'
import Delta from 'quill-delta'
import { DateTimeUtils } from 'src/common/utils/datetime.utils' import { DateTimeUtils } from 'src/common/utils/datetime.utils'
import { v4 as uuidv4 } from 'uuid' import { v4 as uuidv4 } from 'uuid'
import Delta from 'quill-delta'
@Injectable() @Injectable()
export class MinioService { export class MinioService {
constructor( 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 // 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) { async getRoomRecordUrl(roomId: string) {
return await new Promise<string | null>(async (resolve, reject) => { 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[] = [] const items: BucketItem[] = []
stream.on('data', (item) => { stream.on('data', (item) => {
@@ -149,7 +153,15 @@ export class MinioService {
}) })
stream.on('end', async () => { stream.on('end', async () => {
const record = items.find((item) => item.name?.endsWith('.mp4')) 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) => { stream.on('error', (err) => {
reject(err) reject(err)

View File

@@ -1,6 +1,6 @@
import { Module } from '@nestjs/common' import { Module } from '@nestjs/common'
import { NotificationService } from './notification.service'
import { PubSubModule } from 'src/PubSub/pubsub.module' import { PubSubModule } from 'src/PubSub/pubsub.module'
import { NotificationService } from './notification.service'
@Module({ @Module({
imports: [PubSubModule], imports: [PubSubModule],
providers: [NotificationService], providers: [NotificationService],

View File

@@ -1,9 +1,9 @@
import { Injectable } from '@nestjs/common' 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 { Logger } from '@nestjs/common'
import { MessageContextType, MessageType } from '@prisma/client' 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() @Injectable()
export class NotificationService { export class NotificationService {
constructor( constructor(

View File

@@ -1,9 +1,9 @@
import { readFileSync } from 'fs'
import { Injectable, Logger } from '@nestjs/common' import { Injectable, Logger } from '@nestjs/common'
import { OpenAI } from 'openai' import { OpenAI } from 'openai'
import { zodResponseFormat } from 'openai/helpers/zod'
import Delta from 'quill-delta' import Delta from 'quill-delta'
import { z } from 'zod' import { z } from 'zod'
import { zodResponseFormat } from 'openai/helpers/zod'
import { readFileSync } from 'fs'
const DELTA_INSTRUCTIONS = '' const DELTA_INSTRUCTIONS = ''

View File

@@ -1,6 +1,6 @@
import { Module } from '@nestjs/common' import { Module } from '@nestjs/common'
import { OrderSchema } from './order.schema'
import { PayosModule } from 'src/Payos/payos.module' import { PayosModule } from 'src/Payos/payos.module'
import { OrderSchema } from './order.schema'
@Module({ @Module({
imports: [PayosModule], imports: [PayosModule],
providers: [OrderSchema], providers: [OrderSchema],

View File

@@ -1,11 +1,11 @@
import { Inject, Injectable, Logger } from '@nestjs/common' 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 { OrderStatus, ScheduleDateStatus, ScheduleStatus } from '@prisma/client'
import { DateTimeUtils } from '../common/utils/datetime.utils' import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
import { PayosService } from '../Payos/payos.service'
import _ from 'lodash' 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() @Injectable()
export class OrderSchema extends PothosSchema { export class OrderSchema extends PothosSchema {
constructor( constructor(

View File

@@ -1,13 +1,8 @@
import { Inject, Injectable } from '@nestjs/common' import { Inject, Injectable } from '@nestjs/common'
import { import { PaymentStatus } from '@prisma/client'
Pothos, import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
PothosRef,
PothosSchema,
SchemaBuilderToken,
} from '@smatch-corp/nestjs-pothos'
import { Builder } from '../Graphql/graphql.builder' import { Builder } from '../Graphql/graphql.builder'
import { PrismaService } from '../Prisma/prisma.service' import { PrismaService } from '../Prisma/prisma.service'
import { PaymentStatus } from '@prisma/client'
@Injectable() @Injectable()
export class PaymentSchema extends PothosSchema { export class PaymentSchema extends PothosSchema {
@@ -64,7 +59,7 @@ export class PaymentSchema extends PothosSchema {
type: this.payment(), type: this.payment(),
description: 'Retrieve a single payment by its unique identifier.', description: 'Retrieve a single payment by its unique identifier.',
args: this.builder.generator.findUniqueArgs('Payment'), 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({ return await this.prisma.payment.findUnique({
...query, ...query,
where: args.where, where: args.where,
@@ -74,9 +69,8 @@ export class PaymentSchema extends PothosSchema {
payments: t.prismaField({ payments: t.prismaField({
type: [this.payment()], type: [this.payment()],
args: this.builder.generator.findManyArgs('Payment'), args: this.builder.generator.findManyArgs('Payment'),
description: description: 'Retrieve a list of payments with optional filtering, ordering, and pagination.',
'Retrieve a list of payments with optional filtering, ordering, and pagination.', resolve: async (query, _root, args, _ctx, _info) => {
resolve: async (query, root, args, ctx, info) => {
return await this.prisma.payment.findMany({ return await this.prisma.payment.findMany({
...query, ...query,
where: args.filter ?? undefined, where: args.filter ?? undefined,

View File

@@ -1,16 +1,7 @@
import { import { Body, Controller, Delete, Get, Headers, Param, Post, Put } from '@nestjs/common'
Controller, import { ApiOperation, ApiTags } from '@nestjs/swagger'
Get,
Post,
Put,
Delete,
Param,
Body,
Headers,
} from '@nestjs/common'
import { PayosService } from './payos.service'
import { ApiTags, ApiOperation } from '@nestjs/swagger'
import { WebhookType } from '@payos/node/lib/type' import { WebhookType } from '@payos/node/lib/type'
import { PayosService } from './payos.service'
@ApiTags('Payos') @ApiTags('Payos')
@Controller('payos') @Controller('payos')
@@ -34,6 +25,7 @@ export class PayosController {
// test create payment url // test create payment url
@Post('create-payment-url') @Post('create-payment-url')
@ApiOperation({ summary: 'Test create payment url' }) @ApiOperation({ summary: 'Test create payment url' })
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
async createPaymentURL(@Body() body: any) { async createPaymentURL(@Body() body: any) {
return this.payosService.createPaymentURL(body) return this.payosService.createPaymentURL(body)
} }

View File

@@ -1,8 +1,8 @@
import { HttpModule } from '@nestjs/axios'
import { Module } from '@nestjs/common' import { Module } from '@nestjs/common'
import PayOS from '@payos/node'
import { PayosController } from './payos.controller' import { PayosController } from './payos.controller'
import { PayosService } from './payos.service' import { PayosService } from './payos.service'
import { HttpModule } from '@nestjs/axios'
import PayOS from '@payos/node'
@Module({ @Module({
imports: [HttpModule], imports: [HttpModule],

View File

@@ -1,14 +1,13 @@
import { Inject, Injectable, Logger } from '@nestjs/common' import { Inject, Injectable, Logger } from '@nestjs/common'
import { PrismaService } from '../Prisma/prisma.service'
import PayOS from '@payos/node' import PayOS from '@payos/node'
import type { import type {
CancelPaymentLinkRequestType,
CheckoutRequestType, CheckoutRequestType,
CheckoutResponseDataType, CheckoutResponseDataType,
WebhookType,
WebhookDataType,
CancelPaymentLinkRequestType,
DataType, DataType,
WebhookDataType,
WebhookType,
} from '@payos/node/lib/type' } from '@payos/node/lib/type'
import { import {
ChatRoomType, ChatRoomType,
@@ -18,6 +17,7 @@ import {
ScheduleDateStatus, ScheduleDateStatus,
ScheduleStatus, ScheduleStatus,
} from '@prisma/client' } from '@prisma/client'
import { PrismaService } from '../Prisma/prisma.service'
export type CreatePaymentBody = CheckoutRequestType export type CreatePaymentBody = CheckoutRequestType
export type CreatePaymentResponse = CheckoutResponseDataType export type CreatePaymentResponse = CheckoutResponseDataType
@Injectable() @Injectable()
@@ -47,8 +47,7 @@ export class PayosService {
Logger.error(`Invalid checksum: ${JSON.stringify(data)}`) Logger.error(`Invalid checksum: ${JSON.stringify(data)}`)
throw new Error('Invalid checksum') throw new Error('Invalid checksum')
} }
const paymentStatus = const paymentStatus = paymentData.code === '00' ? PaymentStatus.PAID : PaymentStatus.CANCELLED
paymentData.code === '00' ? PaymentStatus.PAID : PaymentStatus.CANCELLED
/* ---------------------------- begin transaction --------------------------- */ /* ---------------------------- begin transaction --------------------------- */
try { try {
await this.prisma.$transaction(async (tx) => { await this.prisma.$transaction(async (tx) => {
@@ -59,10 +58,7 @@ export class PayosService {
status: paymentStatus, status: paymentStatus,
}, },
}) })
const orderStatus = const orderStatus = paymentStatus === PaymentStatus.PAID ? OrderStatus.PAID : OrderStatus.FAILED
paymentStatus === PaymentStatus.PAID
? OrderStatus.PAID
: OrderStatus.FAILED
// update order status // update order status
await tx.order.update({ await tx.order.update({
where: { id: payment.orderId }, where: { id: payment.orderId },
@@ -129,8 +125,7 @@ export class PayosService {
/* --------------- send first message from mentor to customer --------------- */ /* --------------- send first message from mentor to customer --------------- */
await tx.message.create({ await tx.message.create({
data: { data: {
content: 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é!',
'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, type: MessageType.TEXT,
chatRoomId: chatRoom.id, chatRoomId: chatRoom.id,
senderId: mentorId, senderId: mentorId,
@@ -158,10 +153,7 @@ export class PayosService {
return await this.payos.getPaymentLinkInformation(orderId) return await this.payos.getPaymentLinkInformation(orderId)
} }
async cancelPaymentURL( async cancelPaymentURL(orderId: string | number, cancellationReason?: string) {
orderId: string | number,
cancellationReason?: string,
) {
return await this.payos.cancelPaymentLink(orderId, cancellationReason) return await this.payos.cancelPaymentLink(orderId, cancellationReason)
} }

View File

@@ -1,8 +1,8 @@
import { Inject, Injectable, Logger } from '@nestjs/common' import { Inject, Injectable, Logger } from '@nestjs/common'
import { PersonalMilestoneStatus } from '@prisma/client'
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 { Builder } from '../Graphql/graphql.builder'
import { PrismaService } from '../Prisma/prisma.service' import { PrismaService } from '../Prisma/prisma.service'
import { PersonalMilestoneStatus } from '@prisma/client'
@Injectable() @Injectable()
export class PersonalMilestoneSchema extends PothosSchema { export class PersonalMilestoneSchema extends PothosSchema {

View File

@@ -1,9 +1,4 @@
import { import { INestApplication, Injectable, Logger, OnModuleInit } from '@nestjs/common'
INestApplication,
Injectable,
Logger,
OnModuleInit,
} from '@nestjs/common'
import { PrismaClient } from '@prisma/client' import { PrismaClient } from '@prisma/client'
@@ -51,14 +46,10 @@ export class PrismaService extends PrismaClient implements OnModuleInit {
return return
} catch (error) { } catch (error) {
if (attempt < maxRetry) { if (attempt < maxRetry) {
this.logger.warn( this.logger.warn(`Connection attempt ${attempt} failed. Retrying in ${retryDelay}ms...`)
`Connection attempt ${attempt} failed. Retrying in ${retryDelay}ms...`,
)
await this.delay(retryDelay) await this.delay(retryDelay)
} else { } else {
this.logger.error( this.logger.error(`Failed to connect to the database after ${maxRetry} attempts.`)
`Failed to connect to the database after ${maxRetry} attempts.`,
)
throw error throw error
} }
} }

View File

@@ -1,6 +1,6 @@
import { Global, Module } from '@nestjs/common' import { Global, Module } from '@nestjs/common'
import { PubSubRedisOptions, RedisPubSub } from 'graphql-redis-subscriptions'
import { PubSubService } from './pubsub.service' import { PubSubService } from './pubsub.service'
import { RedisPubSub, PubSubRedisOptions } from 'graphql-redis-subscriptions'
@Global() @Global()
@Module({ @Module({

View File

@@ -1,9 +1,9 @@
import { Inject, Injectable } from '@nestjs/common' 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 { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
import { Builder } from '../Graphql/graphql.builder' import { Builder } from '../Graphql/graphql.builder'
import { PrismaService } from '../Prisma/prisma.service' import { PrismaService } from '../Prisma/prisma.service'
import { AnswerType } from '@prisma/client'
import { QuestionType } from '@prisma/client'
@Injectable() @Injectable()
export class QuizSchema extends PothosSchema { export class QuizSchema extends PothosSchema {

View File

@@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common' import { Injectable } from '@nestjs/common'
import { Redis } from 'ioredis'
import { User } from '@prisma/client' import { User } from '@prisma/client'
import { Redis } from 'ioredis'
@Injectable() @Injectable()
export class RedisService { export class RedisService {

View File

@@ -1,9 +1,9 @@
import { Inject, Injectable } from '@nestjs/common' 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 { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
import { DateTimeUtils } from 'src/common/utils/datetime.utils'
import { Builder } from '../Graphql/graphql.builder' import { Builder } from '../Graphql/graphql.builder'
import { PrismaService } from '../Prisma/prisma.service' 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' import * as banks from '../common/utils/banks.json'
@Injectable() @Injectable()
export class RefundTicketSchema extends PothosSchema { export class RefundTicketSchema extends PothosSchema {

View File

@@ -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 { RestfulService } from './restful.service'
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger'
@ApiTags('Restful') @ApiTags('Restful')
@Controller('restful') @Controller('restful')

View File

@@ -1,8 +1,8 @@
import { Module } from '@nestjs/common' import { Module } from '@nestjs/common'
import { RestfulController } from './restful.controller'
import { RestfulService } from './restful.service'
import { ClerkModule } from '../Clerk/clerk.module' import { ClerkModule } from '../Clerk/clerk.module'
import { PayosModule } from '../Payos/payos.module' import { PayosModule } from '../Payos/payos.module'
import { RestfulController } from './restful.controller'
import { RestfulService } from './restful.service'
@Module({ @Module({
imports: [ClerkModule, PayosModule], imports: [ClerkModule, PayosModule],

View File

@@ -1,9 +1,9 @@
import { Inject, Injectable, Logger } from '@nestjs/common' import { Inject, Injectable, Logger } from '@nestjs/common'
import { ResumeStatus, Role } from '@prisma/client'
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 { Builder } from '../Graphql/graphql.builder'
import { PrismaService } from '../Prisma/prisma.service'
import { MinioService } from '../Minio/minio.service' import { MinioService } from '../Minio/minio.service'
import { ResumeStatus, Role } from '@prisma/client' import { PrismaService } from '../Prisma/prisma.service'
@Injectable() @Injectable()
export class ResumeSchema extends PothosSchema { export class ResumeSchema extends PothosSchema {
constructor( constructor(

View File

@@ -1,13 +1,13 @@
import { Inject, Injectable, Logger } from '@nestjs/common' 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 { 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 { Builder } from '../Graphql/graphql.builder'
import { PrismaService } from '../Prisma/prisma.service' 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 { ScheduleConfigType } from './schedule'
import { DateTimeUtils } from 'src/common/utils/datetime.utils' import { ScheduleService } from './schedule.service'
import { Role } from '@prisma/client'
@Injectable() @Injectable()
export class ScheduleSchema extends PothosSchema { export class ScheduleSchema extends PothosSchema {
constructor( constructor(

View File

@@ -3,12 +3,12 @@ import { DateTimeUtils } from '../common/utils/datetime.utils'
import { Injectable, Logger } from '@nestjs/common' import { Injectable, Logger } from '@nestjs/common'
import { PrismaService } from 'src/Prisma/prisma.service' 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 { Config, Schedule, ScheduleDate } from '@prisma/client'
import { DateTime, Settings, Zone } from 'luxon'
import _ from 'lodash' import _ from 'lodash'
import { DateTime, Settings, Zone } from 'luxon'
import { AppConfigService } from 'src/AppConfig/appconfig.service'
import { ScheduleDateInput } from './schedule' import { ScheduleDateInput } from './schedule'
import { PreviewScheduleType, ScheduleConfigType, ScheduleConfigTypeForCenter, ScheduleSlotType } from './schedule.d'
@Injectable() @Injectable()
export class ScheduleService { export class ScheduleService {

View File

@@ -1,10 +1,10 @@
import { Inject, Injectable, Logger } from '@nestjs/common' 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 { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
import { Builder } from '../Graphql/graphql.builder' 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 { 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 { PubSubEvent } from '../common/pubsub/pubsub-event'
import { DateTimeUtils } from '../common/utils/datetime.utils' import { DateTimeUtils } from '../common/utils/datetime.utils'
@Injectable() @Injectable()

View File

@@ -1,10 +1,5 @@
import { Inject, Injectable } from '@nestjs/common' import { Inject, Injectable } from '@nestjs/common'
import { import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
Pothos,
PothosRef,
PothosSchema,
SchemaBuilderToken,
} from '@smatch-corp/nestjs-pothos'
import { Builder } from '../Graphql/graphql.builder' import { Builder } from '../Graphql/graphql.builder'
import { PrismaService } from '../Prisma/prisma.service' import { PrismaService } from '../Prisma/prisma.service'
@@ -58,8 +53,7 @@ export class ServiceAndCategorySchema extends PothosSchema {
serviceAndCategories: t.prismaField({ serviceAndCategories: t.prismaField({
type: [this.serviceAndCategory()], type: [this.serviceAndCategory()],
args: this.builder.generator.findManyArgs('ServiceAndCategory'), args: this.builder.generator.findManyArgs('ServiceAndCategory'),
description: description: 'Retrieve a list of service and categories with optional filtering, ordering, and pagination.',
'Retrieve a list of service and categories with optional filtering, ordering, and pagination.',
resolve: async (query, _root, args, _ctx, _info) => { resolve: async (query, _root, args, _ctx, _info) => {
return await this.prisma.serviceAndCategory.findMany({ return await this.prisma.serviceAndCategory.findMany({
...query, ...query,

View File

@@ -1,8 +1,8 @@
import { Inject, Injectable, Logger } from '@nestjs/common' 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 { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
import { Builder } from '../Graphql/graphql.builder' import { Builder } from '../Graphql/graphql.builder'
import { PrismaService } from '../Prisma/prisma.service' import { PrismaService } from '../Prisma/prisma.service'
import { OrderStatus, Role, ScheduleStatus } from '@prisma/client'
@Injectable() @Injectable()
export class ServiceFeedbackSchema extends PothosSchema { export class ServiceFeedbackSchema extends PothosSchema {

View File

@@ -1,6 +1,6 @@
import { Module, Global } from '@nestjs/common' import { Global, Module } from '@nestjs/common'
import { UploadedFileSchema } from './uploadedfile.schema'
import { MinioModule } from '../Minio/minio.module' import { MinioModule } from '../Minio/minio.module'
import { UploadedFileSchema } from './uploadedfile.schema'
@Global() @Global()
@Module({ @Module({
imports: [MinioModule], imports: [MinioModule],

View File

@@ -1,14 +1,9 @@
import { Inject, Injectable } from '@nestjs/common' import { Inject, Injectable } from '@nestjs/common'
import { import { UploadedFileType } from '@prisma/client'
Pothos, import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
PothosRef, import { MinioService } from 'src/Minio/minio.service'
PothosSchema,
SchemaBuilderToken,
} from '@smatch-corp/nestjs-pothos'
import { Builder } from '../Graphql/graphql.builder' import { Builder } from '../Graphql/graphql.builder'
import { PrismaService } from '../Prisma/prisma.service' import { PrismaService } from '../Prisma/prisma.service'
import { MinioService } from 'src/Minio/minio.service'
import { UploadedFileType } from '@prisma/client'
@Injectable() @Injectable()
export class UploadedFileSchema extends PothosSchema { export class UploadedFileSchema extends PothosSchema {
constructor( constructor(
@@ -45,11 +40,7 @@ export class UploadedFileSchema extends PothosSchema {
nullable: true, nullable: true,
description: 'The URL of the file.', description: 'The URL of the file.',
resolve: async (file) => { resolve: async (file) => {
return await this.minioService.updatePresignUrl( return await this.minioService.updatePresignUrl(file.fileName, 'files', file.fileUrl)
file.fileName,
'files',
file.fileUrl,
)
}, },
}), }),
uploadedAt: t.expose('uploadedAt', { uploadedAt: t.expose('uploadedAt', {
@@ -77,8 +68,7 @@ export class UploadedFileSchema extends PothosSchema {
init(): void { init(): void {
this.builder.queryFields((t) => ({ this.builder.queryFields((t) => ({
uploadedFile: t.prismaField({ uploadedFile: t.prismaField({
description: description: 'Retrieve a single uploaded file by its unique identifier.',
'Retrieve a single uploaded file by its unique identifier.',
type: this.uploadedFile(), type: this.uploadedFile(),
args: this.builder.generator.findUniqueArgs('UploadedFile'), args: this.builder.generator.findUniqueArgs('UploadedFile'),
resolve: async (query, _root, args) => { resolve: async (query, _root, args) => {
@@ -89,10 +79,7 @@ export class UploadedFileSchema extends PothosSchema {
if (!file) { if (!file) {
throw new Error('File not found') throw new Error('File not found')
} }
const fileUrl = await this.minioService.getFileUrl( const fileUrl = await this.minioService.getFileUrl(file.fileName, 'files')
file.fileName,
'files',
)
if (!fileUrl) { if (!fileUrl) {
throw new Error('Cannot retrieve file url') throw new Error('Cannot retrieve file url')
} }
@@ -101,8 +88,7 @@ export class UploadedFileSchema extends PothosSchema {
}, },
}), }),
uploadedFiles: t.prismaField({ uploadedFiles: t.prismaField({
description: description: 'Retrieve a list of uploaded files with optional filtering, ordering, and pagination.',
'Retrieve a list of uploaded files with optional filtering, ordering, and pagination.',
type: [this.uploadedFile()], type: [this.uploadedFile()],
args: this.builder.generator.findManyArgs('UploadedFile'), args: this.builder.generator.findManyArgs('UploadedFile'),
resolve: async (query, _root, args) => { resolve: async (query, _root, args) => {
@@ -113,9 +99,7 @@ export class UploadedFileSchema extends PothosSchema {
orderBy: args.orderBy ?? undefined, orderBy: args.orderBy ?? undefined,
where: args.filter ?? undefined, where: args.filter ?? undefined,
}) })
const fileUrls = await Promise.all( const fileUrls = await Promise.all(files.map((file) => this.minioService.getFileUrl(file.id, 'files')))
files.map((file) => this.minioService.getFileUrl(file.id, 'files')),
)
return files.map((file, index) => ({ return files.map((file, index) => ({
...file, ...file,
fileUrl: fileUrls[index] ?? '', fileUrl: fileUrls[index] ?? '',
@@ -152,8 +136,7 @@ export class UploadedFileSchema extends PothosSchema {
if (!user) { if (!user) {
throw new Error('User not found') throw new Error('User not found')
} }
const { filename, mimetype, actualFileName } = const { filename, mimetype, actualFileName } = await this.minioService.uploadFile(args.file, 'files')
await this.minioService.uploadFile(args.file, 'files')
if (!mimetype) { if (!mimetype) {
throw new Error('File type not supported') throw new Error('File type not supported')
} }
@@ -202,16 +185,10 @@ export class UploadedFileSchema extends PothosSchema {
if (!user) { if (!user) {
throw new Error('User not found') throw new Error('User not found')
} }
const uploadedFiles = await Promise.all( const uploadedFiles = await Promise.all(args.files.map((file) => this.minioService.uploadFile(file, 'files')))
args.files.map((file) =>
this.minioService.uploadFile(file, 'files'),
),
)
// get file urls // get file urls
const fileUrls = await Promise.all( const fileUrls = await Promise.all(
uploadedFiles.map((file) => uploadedFiles.map((file) => this.minioService.getFileUrl(file.filename, 'files')),
this.minioService.getFileUrl(file.filename, 'files'),
),
) )
// map uploadedFiles to db // map uploadedFiles to db
const dbFiles = uploadedFiles.map((file, index) => ({ const dbFiles = uploadedFiles.map((file, index) => ({
@@ -224,8 +201,7 @@ export class UploadedFileSchema extends PothosSchema {
uploadedAt: new Date(), uploadedAt: new Date(),
})) }))
// create files in db // create files in db
const createdFiles = const createdFiles = await this.prisma.uploadedFile.createManyAndReturn({
await this.prisma.uploadedFile.createManyAndReturn({
data: dbFiles, data: dbFiles,
}) })
return createdFiles return createdFiles
@@ -261,8 +237,7 @@ export class UploadedFileSchema extends PothosSchema {
}), }),
deleteUploadedFiles: t.prismaField({ deleteUploadedFiles: t.prismaField({
description: description: 'Delete multiple uploaded files by their unique identifiers.',
'Delete multiple uploaded files by their unique identifiers.',
type: [this.uploadedFile()], type: [this.uploadedFile()],
args: { args: {
ids: t.arg({ ids: t.arg({
@@ -285,11 +260,7 @@ export class UploadedFileSchema extends PothosSchema {
}, },
}, },
}) })
await Promise.all( await Promise.all(files.map((file) => this.minioService.deleteFile(file.fileName, 'files')))
files.map((file) =>
this.minioService.deleteFile(file.fileName, 'files'),
),
)
return files return files
}, },
}), }),

View File

@@ -1,7 +1,7 @@
import { Module } from '@nestjs/common' import { Module } from '@nestjs/common'
import { UserSchema } from './user.schema'
import { MessageModule } from '../Message/message.module'
import { ChatroomModule } from '../ChatRoom/chatroom.module' import { ChatroomModule } from '../ChatRoom/chatroom.module'
import { MessageModule } from '../Message/message.module'
import { UserSchema } from './user.schema'
@Module({ @Module({
imports: [MessageModule, ChatroomModule], imports: [MessageModule, ChatroomModule],
providers: [UserSchema], providers: [UserSchema],

View File

@@ -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 { clerkClient } from '@clerk/express'
import { MailService } from '../Mail/mail.service' import { Inject, Injectable, Logger } from '@nestjs/common'
import { MessageSchema } from 'src/Message/message.schema'
import { ChatRoom, Message, MessageContextType, MessageType, Role } from '@prisma/client' import { ChatRoom, Message, MessageContextType, MessageType, Role } from '@prisma/client'
import { PubSubEvent } from 'src/common/pubsub/pubsub-event' import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
import { DateTimeUtils } from 'src/common/utils/datetime.utils'
import { ChatroomSchema } from '../ChatRoom/chatroom.schema' 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() @Injectable()
export class UserSchema extends PothosSchema { export class UserSchema extends PothosSchema {
constructor( constructor(

View File

@@ -1,9 +1,9 @@
import { Inject, Injectable } from '@nestjs/common' import { Inject, Injectable } from '@nestjs/common'
import { Role } from '@prisma/client'
import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos' import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
import { MinioService } from 'src/Minio/minio.service'
import { Builder } from '../Graphql/graphql.builder' import { Builder } from '../Graphql/graphql.builder'
import { PrismaService } from '../Prisma/prisma.service' import { PrismaService } from '../Prisma/prisma.service'
import { MinioService } from 'src/Minio/minio.service'
import { Role } from '@prisma/client'
@Injectable() @Injectable()
export class WorkshopSchema extends PothosSchema { export class WorkshopSchema extends PothosSchema {

View File

@@ -1,4 +1,4 @@
import { Module, Global } from '@nestjs/common' import { Global, Module } from '@nestjs/common'
import { WorkshopMeetingRoomSchema } from './workshopmeetingroom.schema' import { WorkshopMeetingRoomSchema } from './workshopmeetingroom.schema'
@Module({ @Module({

View File

@@ -1,8 +1,8 @@
import { Inject, Injectable } from '@nestjs/common' 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 { Builder } from '../Graphql/graphql.builder'
import { PrismaService } from '../Prisma/prisma.service'
import { LiveKitService } from '../LiveKit/livekit.service' import { LiveKitService } from '../LiveKit/livekit.service'
import { PrismaService } from '../Prisma/prisma.service'
@Injectable() @Injectable()
export class WorkshopMeetingRoomSchema extends PothosSchema { export class WorkshopMeetingRoomSchema extends PothosSchema {
constructor( constructor(

View File

@@ -1,10 +1,5 @@
import { Inject, Injectable } from '@nestjs/common' import { Inject, Injectable } from '@nestjs/common'
import { import { Pothos, PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
Pothos,
PothosRef,
PothosSchema,
SchemaBuilderToken,
} from '@smatch-corp/nestjs-pothos'
import { Builder } from '../Graphql/graphql.builder' import { Builder } from '../Graphql/graphql.builder'
import { PrismaService } from '../Prisma/prisma.service' import { PrismaService } from '../Prisma/prisma.service'
@@ -34,8 +29,7 @@ export class WorkshopOrganizationSchema extends PothosSchema {
}), }),
createdAt: t.expose('createdAt', { createdAt: t.expose('createdAt', {
type: 'DateTime', type: 'DateTime',
description: description: 'The date and time the workshop organization was created.',
'The date and time the workshop organization was created.',
}), }),
}), }),
}) })

View File

@@ -1,8 +1,8 @@
import { Inject, Injectable } from '@nestjs/common' 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 { DateTimeUtils } from 'src/common/utils/datetime.utils'
import { Builder } from '../Graphql/graphql.builder' import { Builder } from '../Graphql/graphql.builder'
import { PrismaService } from '../Prisma/prisma.service' import { PrismaService } from '../Prisma/prisma.service'
import { DateTimeUtils } from 'src/common/utils/datetime.utils'
@Injectable() @Injectable()
export class WorkshopSubscriptionSchema extends PothosSchema { export class WorkshopSubscriptionSchema extends PothosSchema {

View File

@@ -1,10 +1,10 @@
import { ClerkModule } from './Clerk/clerk.module' import { Module } from '@nestjs/common'
import { ConfigModule } from '@nestjs/config' import { ConfigModule } from '@nestjs/config'
import { ClerkModule } from './Clerk/clerk.module'
import { CronModule } from './Cron/cron.module'
import { GraphqlModule } from './Graphql/graphql.module' import { GraphqlModule } from './Graphql/graphql.module'
import { MailModule } from './Mail/mail.module' import { MailModule } from './Mail/mail.module'
import { Module } from '@nestjs/common'
import { RestfulModule } from './Restful/restful.module' import { RestfulModule } from './Restful/restful.module'
import { CronModule } from './Cron/cron.module'
@Module({ @Module({
imports: [ imports: [

View File

@@ -1,10 +1,6 @@
import { Inject, Injectable } from '@nestjs/common' import { Inject, Injectable } from '@nestjs/common'
import { PothosRef, PothosSchema, SchemaBuilderToken } from '@smatch-corp/nestjs-pothos'
import { Builder } from '../../Graphql/graphql.builder' import { Builder } from '../../Graphql/graphql.builder'
import {
PothosRef,
PothosSchema,
SchemaBuilderToken,
} from '@smatch-corp/nestjs-pothos'
@Injectable() @Injectable()
export class CommonGraphqlError extends PothosSchema { export class CommonGraphqlError extends PothosSchema {

View File

@@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common' import { Injectable } from '@nestjs/common'
import _ from 'lodash' 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.defaultLocale = 'en-US'
Settings.defaultZone = 'utc' Settings.defaultZone = 'utc'

View File

@@ -1,14 +1,14 @@
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger' 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 { Logger } from '@nestjs/common'
import { NestFactory } from '@nestjs/core' import { NestFactory } from '@nestjs/core'
import { clerkMiddleware } from '@clerk/express' import { json } from 'express'
// @ts-expect-error // @ts-expect-error
import graphqlUploadExpress from 'graphql-upload/graphqlUploadExpress.mjs' import graphqlUploadExpress from 'graphql-upload/graphqlUploadExpress.mjs'
import path from 'node:path' import { AppModule } from './app.module'
import { readFileSync } from 'node:fs'
import { json } from 'express'
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(AppModule, {}) const app = await NestFactory.create(AppModule, {})

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +1,5 @@
import { Test, TestingModule } from '@nestjs/testing'
import { INestApplication } from '@nestjs/common' import { INestApplication } from '@nestjs/common'
import { Test, TestingModule } from '@nestjs/testing'
import * as request from 'supertest' import * as request from 'supertest'
import { AppModule } from './../src/app.module' import { AppModule } from './../src/app.module'
@@ -16,9 +16,6 @@ describe('AppController (e2e)', () => {
}) })
it('/ (GET)', () => { it('/ (GET)', () => {
return request(app.getHttpServer()) return request(app.getHttpServer()).get('/').expect(200).expect('Hello World!')
.get('/')
.expect(200)
.expect('Hello World!')
}) })
}) })

View File

@@ -1,13 +1,6 @@
{ {
"extends": "./tsconfig.json", "extends": "./tsconfig.json",
"exclude": [ "exclude": ["node_modules", "test", "dist", "**/*spec.ts", "epess-database", "codegen.ts"],
"node_modules",
"test",
"dist",
"**/*spec.ts",
"epess-database",
"codegen.ts",
],
"compilerOptions": { "compilerOptions": {
"rootDir": "./src", "rootDir": "./src",
"allowJs": true "allowJs": true

View File

@@ -21,6 +21,6 @@
"allowJs": true, "allowJs": true,
"maxNodeModuleJsDepth": 10, "maxNodeModuleJsDepth": 10,
"resolveJsonModule": true, "resolveJsonModule": true,
"moduleResolution": "nodenext", "moduleResolution": "nodenext"
} }
} }