fix(api): resolve NestJS DI + ValidationPipe bugs from type-only imports
- Remove `type` modifier from imports used as DI constructor params across ~235 files (@Injectable, @Controller, @Module, @Catch, @CommandHandler, @QueryHandler, @EventsHandler, @WebSocketGateway). TypeScript emitDecoratorMetadata strips type-only imports, leaving Reflect.metadata with Function placeholder and breaking Nest DI. - Fix controllers: DTOs used with @Body/@Query/@Param must be runtime imports so ValidationPipe can whitelist properties. Previously returned 400 "property X should not exist" on every request. - Register ProjectsModule in AppModule (was defined but never wired). - Add approve()/reject() methods to TransferListingEntity referenced by ModerateTransferListingHandler. - Export BankTransferConfirmedEvent from payments barrel for subscription activation handler. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { HttpStatus, Inject, InternalServerErrorException } from '@nestjs/common';
|
||||
import { CommandHandler, type EventBus, type ICommandHandler } from '@nestjs/cqrs';
|
||||
import { DomainException, ErrorCode, type LoggerService } from '@modules/shared';
|
||||
import { CommandHandler, EventBus, type ICommandHandler } from '@nestjs/cqrs';
|
||||
import { DomainException, ErrorCode, LoggerService } from '@modules/shared';
|
||||
import { ORDER_REPOSITORY, type IOrderRepository } from '../../../domain/repositories/order.repository';
|
||||
import { CancelOrderCommand } from './cancel-order.command';
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import { Inject, InternalServerErrorException } from '@nestjs/common';
|
||||
import { CommandHandler, type EventBus, type ICommandHandler } from '@nestjs/cqrs';
|
||||
import { CommandHandler, EventBus, type ICommandHandler } from '@nestjs/cqrs';
|
||||
import { type PaymentStatus } from '@prisma/client';
|
||||
import {
|
||||
DomainException,
|
||||
NotFoundException,
|
||||
ValidationException,
|
||||
type LoggerService,
|
||||
LoggerService,
|
||||
} from '@modules/shared';
|
||||
import {
|
||||
PAYMENT_REPOSITORY,
|
||||
type IPaymentRepository,
|
||||
} from '../../../domain/repositories/payment.repository';
|
||||
import { type BankTransferService } from '../../../infrastructure/services/bank-transfer.service';
|
||||
import { BankTransferService } from '../../../infrastructure/services/bank-transfer.service';
|
||||
import { ConfirmBankTransferCommand } from './confirm-bank-transfer.command';
|
||||
|
||||
export interface ConfirmBankTransferResult {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Inject, InternalServerErrorException } from '@nestjs/common';
|
||||
import { CommandHandler, type EventBus, type ICommandHandler } from '@nestjs/cqrs';
|
||||
import { CommandHandler, EventBus, type ICommandHandler } from '@nestjs/cqrs';
|
||||
import { createId } from '@paralleldrive/cuid2';
|
||||
import { ConflictException, DomainException, ValidationException, type LoggerService } from '@modules/shared';
|
||||
import { ConflictException, DomainException, ValidationException, LoggerService } from '@modules/shared';
|
||||
import { EscrowEntity } from '../../../domain/entities/escrow.entity';
|
||||
import { OrderEntity } from '../../../domain/entities/order.entity';
|
||||
import { ESCROW_REPOSITORY, type IEscrowRepository } from '../../../domain/repositories/escrow.repository';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Inject, InternalServerErrorException } from '@nestjs/common';
|
||||
import { CommandHandler, type EventBus, type ICommandHandler } from '@nestjs/cqrs';
|
||||
import { CommandHandler, EventBus, type ICommandHandler } from '@nestjs/cqrs';
|
||||
import { createId } from '@paralleldrive/cuid2';
|
||||
import { ConflictException, DomainException, ValidationException, type LoggerService } from '@modules/shared';
|
||||
import { ConflictException, DomainException, ValidationException, LoggerService } from '@modules/shared';
|
||||
import { PaymentEntity } from '../../../domain/entities/payment.entity';
|
||||
import {
|
||||
PAYMENT_REPOSITORY,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Inject, InternalServerErrorException } from '@nestjs/common';
|
||||
import { CommandHandler, type EventBus, type ICommandHandler } from '@nestjs/cqrs';
|
||||
import { CommandHandler, EventBus, type ICommandHandler } from '@nestjs/cqrs';
|
||||
import { type PaymentStatus } from '@prisma/client';
|
||||
import { DomainException, NotFoundException, ValidationException, type LoggerService } from '@modules/shared';
|
||||
import { DomainException, NotFoundException, ValidationException, LoggerService } from '@modules/shared';
|
||||
import {
|
||||
PAYMENT_REPOSITORY,
|
||||
type IPaymentRepository,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { HttpStatus, Inject, InternalServerErrorException } from '@nestjs/common';
|
||||
import { CommandHandler, type EventBus, type ICommandHandler } from '@nestjs/cqrs';
|
||||
import { DomainException, ErrorCode, type LoggerService } from '@modules/shared';
|
||||
import { CommandHandler, EventBus, type ICommandHandler } from '@nestjs/cqrs';
|
||||
import { DomainException, ErrorCode, LoggerService } from '@modules/shared';
|
||||
import { ESCROW_REPOSITORY, type IEscrowRepository } from '../../../domain/repositories/escrow.repository';
|
||||
import { ORDER_REPOSITORY, type IOrderRepository } from '../../../domain/repositories/order.repository';
|
||||
import { HoldEscrowCommand } from './hold-escrow.command';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Inject, InternalServerErrorException } from '@nestjs/common';
|
||||
import { CommandHandler, type ICommandHandler } from '@nestjs/cqrs';
|
||||
import { DomainException, NotFoundException, ValidationException, type LoggerService } from '@modules/shared';
|
||||
import { DomainException, NotFoundException, ValidationException, LoggerService } from '@modules/shared';
|
||||
import {
|
||||
PAYMENT_REPOSITORY,
|
||||
type IPaymentRepository,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { HttpStatus, Inject, InternalServerErrorException } from '@nestjs/common';
|
||||
import { CommandHandler, type EventBus, type ICommandHandler } from '@nestjs/cqrs';
|
||||
import { DomainException, ErrorCode, type LoggerService } from '@modules/shared';
|
||||
import { CommandHandler, EventBus, type ICommandHandler } from '@nestjs/cqrs';
|
||||
import { DomainException, ErrorCode, LoggerService } from '@modules/shared';
|
||||
import { ESCROW_REPOSITORY, type IEscrowRepository } from '../../../domain/repositories/escrow.repository';
|
||||
import { ORDER_REPOSITORY, type IOrderRepository } from '../../../domain/repositories/order.repository';
|
||||
import { ReleaseEscrowCommand } from './release-escrow.command';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Inject, InternalServerErrorException } from '@nestjs/common';
|
||||
import { type IQueryHandler, QueryHandler } from '@nestjs/cqrs';
|
||||
import { DomainException, ForbiddenException, type LoggerService, NotFoundException } from '@modules/shared';
|
||||
import { DomainException, ForbiddenException, LoggerService, NotFoundException } from '@modules/shared';
|
||||
import {
|
||||
PAYMENT_REPOSITORY,
|
||||
type IPaymentRepository,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Inject, InternalServerErrorException } from '@nestjs/common';
|
||||
import { type IQueryHandler, QueryHandler } from '@nestjs/cqrs';
|
||||
import { DomainException, type LoggerService } from '@modules/shared';
|
||||
import { DomainException, LoggerService } from '@modules/shared';
|
||||
import {
|
||||
PAYMENT_REPOSITORY,
|
||||
type IPaymentRepository,
|
||||
|
||||
@@ -16,6 +16,7 @@ export type { CreatePaymentResult } from './application/commands/create-payment/
|
||||
export { PaymentCompletedEvent } from './domain/events/payment-completed.event';
|
||||
export { PaymentFailedEvent } from './domain/events/payment-failed.event';
|
||||
export { PaymentRefundedEvent } from './domain/events/payment-refunded.event';
|
||||
export { BankTransferConfirmedEvent } from './domain/events/bank-transfer-confirmed.event';
|
||||
|
||||
// Domain Events — Order
|
||||
export { OrderCreatedEvent } from './domain/events/order-created.event';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { type Escrow as PrismaEscrow } from '@prisma/client';
|
||||
import { type PrismaService } from '@modules/shared';
|
||||
import { PrismaService } from '@modules/shared';
|
||||
import { EscrowEntity, type EscrowProps } from '../../domain/entities/escrow.entity';
|
||||
import { type IEscrowRepository } from '../../domain/repositories/escrow.repository';
|
||||
import { Money } from '../../domain/value-objects/money.vo';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { type Prisma, type Order as PrismaOrder, type OrderStatus } from '@prisma/client';
|
||||
import { type PrismaService } from '@modules/shared';
|
||||
import { PrismaService } from '@modules/shared';
|
||||
import { OrderEntity, type OrderProps } from '../../domain/entities/order.entity';
|
||||
import { type IOrderRepository } from '../../domain/repositories/order.repository';
|
||||
import { Money } from '../../domain/value-objects/money.vo';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Prisma, type Payment as PrismaPayment, type PaymentStatus } from '@prisma/client';
|
||||
import { type PrismaService } from '@modules/shared';
|
||||
import { PrismaService } from '@modules/shared';
|
||||
import { PaymentEntity, type PaymentProps } from '../../domain/entities/payment.entity';
|
||||
import { type IPaymentRepository } from '../../domain/repositories/payment.repository';
|
||||
import { Money } from '../../domain/value-objects/money.vo';
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import * as crypto from 'crypto';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { type ConfigService } from '@nestjs/config';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { type PaymentProvider } from '@prisma/client';
|
||||
import { type LoggerService } from '@modules/shared';
|
||||
import { LoggerService } from '@modules/shared';
|
||||
import {
|
||||
type IPaymentGateway,
|
||||
type CreatePaymentUrlParams,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import * as crypto from 'crypto';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { type ConfigService } from '@nestjs/config';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { type PaymentProvider } from '@prisma/client';
|
||||
import { type LoggerService } from '@modules/shared';
|
||||
import { LoggerService } from '@modules/shared';
|
||||
import {
|
||||
type IPaymentGateway,
|
||||
type CreatePaymentUrlParams,
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { Injectable, BadRequestException } from '@nestjs/common';
|
||||
import { type PaymentProvider } from '@prisma/client';
|
||||
import { type BankTransferService } from './bank-transfer.service';
|
||||
import { type MomoService } from './momo.service';
|
||||
import { BankTransferService } from './bank-transfer.service';
|
||||
import { MomoService } from './momo.service';
|
||||
import {
|
||||
type IPaymentGateway,
|
||||
type IPaymentGatewayFactory,
|
||||
} from './payment-gateway.interface';
|
||||
import { type VnpayService } from './vnpay.service';
|
||||
import { type ZalopayService } from './zalopay.service';
|
||||
import { VnpayService } from './vnpay.service';
|
||||
import { ZalopayService } from './zalopay.service';
|
||||
|
||||
@Injectable()
|
||||
export class PaymentGatewayFactory implements IPaymentGatewayFactory {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import * as crypto from 'crypto';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { type ConfigService } from '@nestjs/config';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { type PaymentProvider } from '@prisma/client';
|
||||
import { type LoggerService } from '@modules/shared';
|
||||
import { LoggerService } from '@modules/shared';
|
||||
import {
|
||||
type IPaymentGateway,
|
||||
type CreatePaymentUrlParams,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import * as crypto from 'crypto';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { type ConfigService } from '@nestjs/config';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { type PaymentProvider } from '@prisma/client';
|
||||
import { type LoggerService } from '@modules/shared';
|
||||
import { LoggerService } from '@modules/shared';
|
||||
import {
|
||||
type IPaymentGateway,
|
||||
type CreatePaymentUrlParams,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Body, Controller, Param, Post, UseGuards } from '@nestjs/common';
|
||||
import { type CommandBus } from '@nestjs/cqrs';
|
||||
import { CommandBus } from '@nestjs/cqrs';
|
||||
import {
|
||||
ApiBearerAuth,
|
||||
ApiOperation,
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
import { CurrentUser, JwtAuthGuard, type JwtPayload, Roles, RolesGuard } from '@modules/auth';
|
||||
import { ConfirmBankTransferCommand } from '../../application/commands/confirm-bank-transfer/confirm-bank-transfer.command';
|
||||
import { type ConfirmBankTransferResult } from '../../application/commands/confirm-bank-transfer/confirm-bank-transfer.handler';
|
||||
import { type ConfirmBankTransferDto } from '../dto/confirm-bank-transfer.dto';
|
||||
import { ConfirmBankTransferDto } from '../dto/confirm-bank-transfer.dto';
|
||||
|
||||
/**
|
||||
* Admin-only controller for manual payment reconciliation.
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
Post,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { type CommandBus, type QueryBus } from '@nestjs/cqrs';
|
||||
import { CommandBus, QueryBus } from '@nestjs/cqrs';
|
||||
import {
|
||||
ApiTags,
|
||||
ApiOperation,
|
||||
@@ -24,8 +24,8 @@ import { ReleaseEscrowCommand } from '../../application/commands/release-escrow/
|
||||
import { type ReleaseEscrowResult } from '../../application/commands/release-escrow/release-escrow.handler';
|
||||
import { type OrderStatusDto } from '../../application/queries/get-order-status/get-order-status.handler';
|
||||
import { GetOrderStatusQuery } from '../../application/queries/get-order-status/get-order-status.query';
|
||||
import { type CancelOrderDto } from '../dto/cancel-order.dto';
|
||||
import { type CreateOrderDto } from '../dto/create-order.dto';
|
||||
import { CancelOrderDto } from '../dto/cancel-order.dto';
|
||||
import { CreateOrderDto } from '../dto/create-order.dto';
|
||||
|
||||
@ApiTags('orders')
|
||||
@Controller('orders')
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
Query,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { type CommandBus, type QueryBus } from '@nestjs/cqrs';
|
||||
import { CommandBus, QueryBus } from '@nestjs/cqrs';
|
||||
import {
|
||||
ApiTags,
|
||||
ApiOperation,
|
||||
@@ -32,10 +32,10 @@ import { type PaymentStatusDto } from '../../application/queries/get-payment-sta
|
||||
import { GetPaymentStatusQuery } from '../../application/queries/get-payment-status/get-payment-status.query';
|
||||
import { type TransactionListDto } from '../../application/queries/list-transactions/list-transactions.handler';
|
||||
import { ListTransactionsQuery } from '../../application/queries/list-transactions/list-transactions.query';
|
||||
import { type ConfirmBankTransferDto } from '../dto/confirm-bank-transfer.dto';
|
||||
import { type CreatePaymentDto } from '../dto/create-payment.dto';
|
||||
import { type ListTransactionsDto } from '../dto/list-transactions.dto';
|
||||
import { type RefundPaymentDto } from '../dto/refund-payment.dto';
|
||||
import { ConfirmBankTransferDto } from '../dto/confirm-bank-transfer.dto';
|
||||
import { CreatePaymentDto } from '../dto/create-payment.dto';
|
||||
import { ListTransactionsDto } from '../dto/list-transactions.dto';
|
||||
import { RefundPaymentDto } from '../dto/refund-payment.dto';
|
||||
|
||||
@ApiTags('payments')
|
||||
@Controller('payments')
|
||||
|
||||
Reference in New Issue
Block a user