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

View File

@@ -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)
}

View File

@@ -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],

View File

@@ -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)
}