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 { Inject } from '@nestjs/common';
|
||||
import { type ICommandHandler, CommandHandler } from '@nestjs/cqrs';
|
||||
import { type EventBusService, NotFoundException } from '@modules/shared';
|
||||
import { EventBusService, NotFoundException } from '@modules/shared';
|
||||
import { TransferListingUpdatedEvent } from '../../../domain/events';
|
||||
import {
|
||||
TRANSFER_LISTING_REPOSITORY,
|
||||
|
||||
@@ -143,6 +143,21 @@ export class TransferListingEntity extends AggregateRoot<string> {
|
||||
get expiresAt() { return this._expiresAt; }
|
||||
get publishedAt() { return this._publishedAt; }
|
||||
|
||||
approve(moderationScore?: number, notes?: string): void {
|
||||
this._status = 'ACTIVE';
|
||||
this._moderationScore = moderationScore ?? null;
|
||||
this._moderationNotes = notes ?? null;
|
||||
this._publishedAt = new Date();
|
||||
this.updatedAt = new Date();
|
||||
}
|
||||
|
||||
reject(moderationScore?: number, notes?: string): void {
|
||||
this._status = 'REJECTED';
|
||||
this._moderationScore = moderationScore ?? null;
|
||||
this._moderationNotes = notes ?? null;
|
||||
this.updatedAt = new Date();
|
||||
}
|
||||
|
||||
updateDetails(props: Partial<TransferListingProps>): void {
|
||||
if (props.sellerId !== undefined) this._sellerId = props.sellerId;
|
||||
if (props.category !== undefined) this._category = props.category;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { OnEvent } from '@nestjs/event-emitter';
|
||||
import { type LoggerService } from '@modules/shared';
|
||||
import { LoggerService } from '@modules/shared';
|
||||
import { type TransferListingCreatedEvent } from '../../domain/events/transfer-listing-created.event';
|
||||
import { type TransferListingUpdatedEvent } from '../../domain/events/transfer-listing-updated.event';
|
||||
import { type TransferListingDeletedEvent } from '../../domain/events/transfer-listing-deleted.event';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { createId } from '@paralleldrive/cuid2';
|
||||
import type { Prisma } from '@prisma/client';
|
||||
import { type PrismaService } from '@modules/shared';
|
||||
import { PrismaService } from '@modules/shared';
|
||||
import type { CreateTransferItemInput } from '../../application/commands/create-transfer-listing/create-transfer-listing.command';
|
||||
import { TransferListingEntity } from '../../domain/entities/transfer-listing.entity';
|
||||
import type {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { createHash } from 'crypto';
|
||||
import Anthropic from '@anthropic-ai/sdk';
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { type ConfigService } from '@nestjs/config';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import type { TransferCategory, TransferCondition } from '@prisma/client';
|
||||
import { CachePrefix, type CacheService } from '@modules/shared';
|
||||
import { CachePrefix, CacheService } from '@modules/shared';
|
||||
|
||||
export interface VisionAssessmentInput {
|
||||
imageUrls?: string[];
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Injectable, type OnModuleInit } from '@nestjs/common';
|
||||
import { type Client as TypesenseClient } from 'typesense';
|
||||
import { type CollectionCreateSchema } from 'typesense/lib/Typesense/Collections';
|
||||
import { type TypesenseClientService } from '@modules/search';
|
||||
import { type LoggerService, type PrismaService } from '@modules/shared';
|
||||
import { TypesenseClientService } from '@modules/search';
|
||||
import { LoggerService, PrismaService } from '@modules/shared';
|
||||
|
||||
export const TRANSFER_LISTINGS_COLLECTION = 'transfer_listings';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Body, Controller, Delete, Get, Param, Patch, Post, Query, UseGuards } from '@nestjs/common';
|
||||
import { type CommandBus, type QueryBus } from '@nestjs/cqrs';
|
||||
import { CommandBus, QueryBus } from '@nestjs/cqrs';
|
||||
import { ApiBearerAuth, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||
import { JwtAuthGuard, CurrentUser } from '@modules/auth';
|
||||
import { EndpointRateLimit, EndpointRateLimitGuard, NotFoundException } from '@modules/shared';
|
||||
@@ -11,11 +11,11 @@ import { UpdateTransferListingCommand } from '../../application/commands/update-
|
||||
import { GetTransferListingQuery } from '../../application/queries/get-transfer-listing/get-transfer-listing.query';
|
||||
import { ListTransferListingsQuery } from '../../application/queries/list-transfer-listings/list-transfer-listings.query';
|
||||
import { TransferStatsQuery } from '../../application/queries/transfer-stats/transfer-stats.query';
|
||||
import { type CreateTransferListingDto } from '../dto/create-transfer-listing.dto';
|
||||
import { type EstimateFromPhotosDto } from '../dto/estimate-from-photos.dto';
|
||||
import { type EstimateTransferPricesDto } from '../dto/estimate-transfer-prices.dto';
|
||||
import { type SearchTransferListingsDto } from '../dto/search-transfer-listings.dto';
|
||||
import { type UpdateTransferListingDto } from '../dto/update-transfer-listing.dto';
|
||||
import { CreateTransferListingDto } from '../dto/create-transfer-listing.dto';
|
||||
import { EstimateFromPhotosDto } from '../dto/estimate-from-photos.dto';
|
||||
import { EstimateTransferPricesDto } from '../dto/estimate-transfer-prices.dto';
|
||||
import { SearchTransferListingsDto } from '../dto/search-transfer-listings.dto';
|
||||
import { UpdateTransferListingDto } from '../dto/update-transfer-listing.dto';
|
||||
|
||||
@ApiTags('transfer')
|
||||
@Controller('transfer')
|
||||
|
||||
Reference in New Issue
Block a user