fix: production readiness — resolve build, lint, and code quality issues
- Fix Next.js build failure: remove duplicate route at (dashboard)/listings/[id] that conflicted with (public)/listings/[id] (same URL path in two route groups) - Fix 772 ESLint errors: auto-fix import ordering (import-x/order), remove unused imports/variables, convert empty interfaces to type aliases, replace require() with ESM imports, fix consistent-type-imports violations - Add CLAUDE.md for developer onboarding documentation - All checks pass: 0 lint errors, typecheck clean, 230 tests passing, build success Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
import { CommandHandler, EventBus, type ICommandHandler } from '@nestjs/cqrs';
|
||||
import { Inject } from '@nestjs/common';
|
||||
import { ValidationException } from '@modules/shared/domain/domain-exception';
|
||||
import { CommandHandler, type EventBus, type ICommandHandler } from '@nestjs/cqrs';
|
||||
import { createId } from '@paralleldrive/cuid2';
|
||||
import { CacheService, CachePrefix } from '@modules/shared/infrastructure/cache.service';
|
||||
import { CreateListingCommand } from './create-listing.command';
|
||||
import { PROPERTY_REPOSITORY, type IPropertyRepository } from '../../../domain/repositories/property.repository';
|
||||
import { LISTING_REPOSITORY, type IListingRepository } from '../../../domain/repositories/listing.repository';
|
||||
import { PropertyEntity } from '../../../domain/entities/property.entity';
|
||||
import { ValidationException } from '@modules/shared/domain/domain-exception';
|
||||
import { type CacheService, CachePrefix } from '@modules/shared/infrastructure/cache.service';
|
||||
import { ListingEntity } from '../../../domain/entities/listing.entity';
|
||||
import { PropertyEntity } from '../../../domain/entities/property.entity';
|
||||
import { LISTING_REPOSITORY, type IListingRepository } from '../../../domain/repositories/listing.repository';
|
||||
import { PROPERTY_REPOSITORY, type IPropertyRepository } from '../../../domain/repositories/property.repository';
|
||||
import { Address } from '../../../domain/value-objects/address.vo';
|
||||
import { GeoPoint } from '../../../domain/value-objects/geo-point.vo';
|
||||
import { Price } from '../../../domain/value-objects/price.vo';
|
||||
import { CreateListingCommand } from './create-listing.command';
|
||||
|
||||
export interface CreateListingResult {
|
||||
listingId: string;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { CommandHandler, EventBus, type ICommandHandler } from '@nestjs/cqrs';
|
||||
import { Inject } from '@nestjs/common';
|
||||
import { CommandHandler, type EventBus, type ICommandHandler } from '@nestjs/cqrs';
|
||||
import { NotFoundException } from '@modules/shared/domain/domain-exception';
|
||||
import { CacheService, CachePrefix } from '@modules/shared/infrastructure/cache.service';
|
||||
import { ModerateListingCommand } from './moderate-listing.command';
|
||||
import { LISTING_REPOSITORY, type IListingRepository } from '../../../domain/repositories/listing.repository';
|
||||
import { ModerateListingCommand } from './moderate-listing.command';
|
||||
|
||||
@CommandHandler(ModerateListingCommand)
|
||||
export class ModerateListingHandler implements ICommandHandler<ModerateListingCommand> {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { CommandHandler, EventBus, type ICommandHandler } from '@nestjs/cqrs';
|
||||
import { Inject } from '@nestjs/common';
|
||||
import { CommandHandler, type EventBus, type ICommandHandler } from '@nestjs/cqrs';
|
||||
import { NotFoundException } from '@modules/shared/domain/domain-exception';
|
||||
import { CacheService, CachePrefix } from '@modules/shared/infrastructure/cache.service';
|
||||
import { UpdateListingStatusCommand } from './update-listing-status.command';
|
||||
import { LISTING_REPOSITORY, type IListingRepository } from '../../../domain/repositories/listing.repository';
|
||||
import { UpdateListingStatusCommand } from './update-listing-status.command';
|
||||
|
||||
@CommandHandler(UpdateListingStatusCommand)
|
||||
export class UpdateListingStatusHandler implements ICommandHandler<UpdateListingStatusCommand> {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { CommandHandler, type ICommandHandler } from '@nestjs/cqrs';
|
||||
import { Inject } from '@nestjs/common';
|
||||
import { CommandHandler, type ICommandHandler } from '@nestjs/cqrs';
|
||||
import { createId } from '@paralleldrive/cuid2';
|
||||
import { NotFoundException, ValidationException } from '@modules/shared/domain/domain-exception';
|
||||
import { UploadMediaCommand } from './upload-media.command';
|
||||
import { PROPERTY_REPOSITORY, type IPropertyRepository } from '../../../domain/repositories/property.repository';
|
||||
import { PropertyMediaEntity } from '../../../domain/entities/property-media.entity';
|
||||
import { PROPERTY_REPOSITORY, type IPropertyRepository } from '../../../domain/repositories/property.repository';
|
||||
import { MEDIA_STORAGE_SERVICE, type IMediaStorageService } from '../../../infrastructure/services/media-storage.service';
|
||||
import { UploadMediaCommand } from './upload-media.command';
|
||||
|
||||
const MAX_MEDIA_PER_PROPERTY = 20;
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { QueryHandler, type IQueryHandler } from '@nestjs/cqrs';
|
||||
import { Inject } from '@nestjs/common';
|
||||
import { QueryHandler, type IQueryHandler } from '@nestjs/cqrs';
|
||||
import { NotFoundException } from '@modules/shared/domain/domain-exception';
|
||||
import { CacheService, CachePrefix, CacheTTL } from '@modules/shared/infrastructure/cache.service';
|
||||
import { GetListingQuery } from './get-listing.query';
|
||||
import { LISTING_REPOSITORY, type IListingRepository } from '../../../domain/repositories/listing.repository';
|
||||
import { type ListingDetailData } from '../../../domain/repositories/listing-read.dto';
|
||||
import { LISTING_REPOSITORY, type IListingRepository } from '../../../domain/repositories/listing.repository';
|
||||
import { GetListingQuery } from './get-listing.query';
|
||||
|
||||
/** @deprecated Use ListingDetailData from listing-read.dto instead */
|
||||
export type ListingDetailDto = ListingDetailData;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { QueryHandler, type IQueryHandler } from '@nestjs/cqrs';
|
||||
import { Inject } from '@nestjs/common';
|
||||
import { GetPendingModerationQuery } from './get-pending-moderation.query';
|
||||
import { LISTING_REPOSITORY, type IListingRepository, type PaginatedResult } from '../../../domain/repositories/listing.repository';
|
||||
import { QueryHandler, type IQueryHandler } from '@nestjs/cqrs';
|
||||
import { type ListingSearchItem } from '../../../domain/repositories/listing-read.dto';
|
||||
import { LISTING_REPOSITORY, type IListingRepository, type PaginatedResult } from '../../../domain/repositories/listing.repository';
|
||||
import { GetPendingModerationQuery } from './get-pending-moderation.query';
|
||||
|
||||
@QueryHandler(GetPendingModerationQuery)
|
||||
export class GetPendingModerationHandler implements IQueryHandler<GetPendingModerationQuery> {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { QueryHandler, type IQueryHandler } from '@nestjs/cqrs';
|
||||
import { Inject } from '@nestjs/common';
|
||||
import { SearchListingsQuery } from './search-listings.query';
|
||||
import { LISTING_REPOSITORY, type IListingRepository, type PaginatedResult } from '../../../domain/repositories/listing.repository';
|
||||
import { QueryHandler, type IQueryHandler } from '@nestjs/cqrs';
|
||||
import { type ListingSearchItem } from '../../../domain/repositories/listing-read.dto';
|
||||
import { LISTING_REPOSITORY, type IListingRepository, type PaginatedResult } from '../../../domain/repositories/listing.repository';
|
||||
import { SearchListingsQuery } from './search-listings.query';
|
||||
|
||||
@QueryHandler(SearchListingsQuery)
|
||||
export class SearchListingsHandler implements IQueryHandler<SearchListingsQuery> {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { AggregateRoot } from '@modules/shared/domain/aggregate-root';
|
||||
import { type ListingStatus, type TransactionType } from '@prisma/client';
|
||||
import { type Price } from '../value-objects/price.vo';
|
||||
import { ListingCreatedEvent } from '../events/listing-created.event';
|
||||
import { ListingApprovedEvent } from '../events/listing-approved.event';
|
||||
import { ListingSoldEvent } from '../events/listing-sold.event';
|
||||
import { AggregateRoot } from '@modules/shared/domain/aggregate-root';
|
||||
import { ValidationException } from '@modules/shared/domain/domain-exception';
|
||||
import { ListingApprovedEvent } from '../events/listing-approved.event';
|
||||
import { ListingCreatedEvent } from '../events/listing-created.event';
|
||||
import { ListingSoldEvent } from '../events/listing-sold.event';
|
||||
import { type Price } from '../value-objects/price.vo';
|
||||
|
||||
const VALID_TRANSITIONS: Record<ListingStatus, ListingStatus[]> = {
|
||||
DRAFT: ['PENDING_REVIEW'],
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { AggregateRoot } from '@modules/shared/domain/aggregate-root';
|
||||
import { type PropertyType, type Direction } from '@prisma/client';
|
||||
import { AggregateRoot } from '@modules/shared/domain/aggregate-root';
|
||||
import { type Address } from '../value-objects/address.vo';
|
||||
import { type GeoPoint } from '../value-objects/geo-point.vo';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { type DomainEvent } from '@modules/shared/domain/domain-event';
|
||||
import { type TransactionType } from '@prisma/client';
|
||||
import { type DomainEvent } from '@modules/shared/domain/domain-event';
|
||||
|
||||
export class ListingCreatedEvent implements DomainEvent {
|
||||
readonly eventName = 'listing.created';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { type DomainEvent } from '@modules/shared/domain/domain-event';
|
||||
import { type ListingStatus } from '@prisma/client';
|
||||
import { type DomainEvent } from '@modules/shared/domain/domain-event';
|
||||
|
||||
export class ListingSoldEvent implements DomainEvent {
|
||||
readonly eventName = 'listing.sold';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { type PropertyEntity } from '../entities/property.entity';
|
||||
import { type PropertyMediaEntity } from '../entities/property-media.entity';
|
||||
import { type PropertyEntity } from '../entities/property.entity';
|
||||
|
||||
export const PROPERTY_REPOSITORY = Symbol('PROPERTY_REPOSITORY');
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ValueObject } from '@modules/shared/domain/value-object';
|
||||
import { Result } from '@modules/shared/domain/result';
|
||||
import { ValueObject } from '@modules/shared/domain/value-object';
|
||||
|
||||
interface AddressProps {
|
||||
address: string;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ValueObject } from '@modules/shared/domain/value-object';
|
||||
import { Result } from '@modules/shared/domain/result';
|
||||
import { ValueObject } from '@modules/shared/domain/value-object';
|
||||
|
||||
interface GeoPointProps {
|
||||
latitude: number;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ValueObject } from '@modules/shared/domain/value-object';
|
||||
import { Result } from '@modules/shared/domain/result';
|
||||
import { ValueObject } from '@modules/shared/domain/value-object';
|
||||
|
||||
interface PriceProps {
|
||||
amountVND: bigint;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { PrismaService } from '@modules/shared/infrastructure/prisma.service';
|
||||
import { type Listing as PrismaListing, type Prisma, type ListingStatus } from '@prisma/client';
|
||||
import { type IListingRepository, type ListingSearchParams, type PaginatedResult } from '../../domain/repositories/listing.repository';
|
||||
import { type ListingDetailData, type ListingSearchItem, type ListingSellerItem } from '../../domain/repositories/listing-read.dto';
|
||||
import { type PrismaService } from '@modules/shared/infrastructure/prisma.service';
|
||||
import { ListingEntity, type ListingProps } from '../../domain/entities/listing.entity';
|
||||
import { type ListingDetailData, type ListingSearchItem, type ListingSellerItem } from '../../domain/repositories/listing-read.dto';
|
||||
import { type IListingRepository, type ListingSearchParams, type PaginatedResult } from '../../domain/repositories/listing.repository';
|
||||
import { Price } from '../../domain/value-objects/price.vo';
|
||||
|
||||
@Injectable()
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { PrismaService } from '@modules/shared/infrastructure/prisma.service';
|
||||
import { type Property as PrismaProperty, type PropertyMedia as PrismaMedia } from '@prisma/client';
|
||||
import { type IPropertyRepository } from '../../domain/repositories/property.repository';
|
||||
import { PropertyEntity, type PropertyProps } from '../../domain/entities/property.entity';
|
||||
import { type PrismaService } from '@modules/shared/infrastructure/prisma.service';
|
||||
import { PropertyMediaEntity, type PropertyMediaProps } from '../../domain/entities/property-media.entity';
|
||||
import { PropertyEntity, type PropertyProps } from '../../domain/entities/property.entity';
|
||||
import { type IPropertyRepository } from '../../domain/repositories/property.repository';
|
||||
import { Address } from '../../domain/value-objects/address.vo';
|
||||
import { GeoPoint } from '../../domain/value-objects/geo-point.vo';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Injectable, OnModuleInit } from '@nestjs/common';
|
||||
import { LoggerService } from '@modules/shared/infrastructure/logger.service';
|
||||
import * as crypto from 'crypto';
|
||||
import * as path from 'path';
|
||||
import {
|
||||
S3Client,
|
||||
PutObjectCommand,
|
||||
@@ -7,8 +7,8 @@ import {
|
||||
HeadBucketCommand,
|
||||
CreateBucketCommand,
|
||||
} from '@aws-sdk/client-s3';
|
||||
import * as crypto from 'crypto';
|
||||
import * as path from 'path';
|
||||
import { Injectable, type OnModuleInit } from '@nestjs/common';
|
||||
import { type LoggerService } from '@modules/shared/infrastructure/logger.service';
|
||||
|
||||
export const MEDIA_STORAGE_SERVICE = Symbol('MEDIA_STORAGE_SERVICE');
|
||||
|
||||
|
||||
@@ -1,28 +1,18 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { CqrsModule } from '@nestjs/cqrs';
|
||||
import { MulterModule } from '@nestjs/platform-express';
|
||||
|
||||
// Domain
|
||||
import { PROPERTY_REPOSITORY } from './domain/repositories/property.repository';
|
||||
import { LISTING_REPOSITORY } from './domain/repositories/listing.repository';
|
||||
|
||||
// Infrastructure
|
||||
import { PrismaPropertyRepository } from './infrastructure/repositories/prisma-property.repository';
|
||||
import { PrismaListingRepository } from './infrastructure/repositories/prisma-listing.repository';
|
||||
import { MEDIA_STORAGE_SERVICE, MinioMediaStorageService } from './infrastructure/services/media-storage.service';
|
||||
|
||||
// Application — Commands
|
||||
import { CreateListingHandler } from './application/commands/create-listing/create-listing.handler';
|
||||
import { ModerateListingHandler } from './application/commands/moderate-listing/moderate-listing.handler';
|
||||
import { UpdateListingStatusHandler } from './application/commands/update-listing-status/update-listing-status.handler';
|
||||
import { UploadMediaHandler } from './application/commands/upload-media/upload-media.handler';
|
||||
import { ModerateListingHandler } from './application/commands/moderate-listing/moderate-listing.handler';
|
||||
|
||||
// Application — Queries
|
||||
import { GetListingHandler } from './application/queries/get-listing/get-listing.handler';
|
||||
import { SearchListingsHandler } from './application/queries/search-listings/search-listings.handler';
|
||||
import { GetPendingModerationHandler } from './application/queries/get-pending-moderation/get-pending-moderation.handler';
|
||||
|
||||
// Presentation
|
||||
import { SearchListingsHandler } from './application/queries/search-listings/search-listings.handler';
|
||||
import { LISTING_REPOSITORY } from './domain/repositories/listing.repository';
|
||||
import { PROPERTY_REPOSITORY } from './domain/repositories/property.repository';
|
||||
import { PrismaListingRepository } from './infrastructure/repositories/prisma-listing.repository';
|
||||
import { PrismaPropertyRepository } from './infrastructure/repositories/prisma-property.repository';
|
||||
import { MEDIA_STORAGE_SERVICE, MinioMediaStorageService } from './infrastructure/services/media-storage.service';
|
||||
import { ListingsController } from './presentation/controllers/listings.controller';
|
||||
|
||||
const CommandHandlers = [
|
||||
|
||||
@@ -10,8 +10,8 @@ import {
|
||||
UseGuards,
|
||||
UseInterceptors,
|
||||
} from '@nestjs/common';
|
||||
import { type CommandBus, type QueryBus } from '@nestjs/cqrs';
|
||||
import { FileInterceptor } from '@nestjs/platform-express';
|
||||
import { CommandBus, QueryBus } from '@nestjs/cqrs';
|
||||
import {
|
||||
ApiTags,
|
||||
ApiOperation,
|
||||
@@ -21,26 +21,26 @@ import {
|
||||
ApiQuery,
|
||||
ApiParam,
|
||||
} from '@nestjs/swagger';
|
||||
import { JwtAuthGuard } from '@modules/auth/presentation/guards/jwt-auth.guard';
|
||||
import { RolesGuard } from '@modules/auth/presentation/guards/roles.guard';
|
||||
import { type JwtPayload } from '@modules/auth/infrastructure/services/token.service';
|
||||
import { CurrentUser } from '@modules/auth/presentation/decorators/current-user.decorator';
|
||||
import { Roles } from '@modules/auth/presentation/decorators/roles.decorator';
|
||||
import { type JwtPayload } from '@modules/auth/infrastructure/services/token.service';
|
||||
import { JwtAuthGuard } from '@modules/auth/presentation/guards/jwt-auth.guard';
|
||||
import { RolesGuard } from '@modules/auth/presentation/guards/roles.guard';
|
||||
import { FileValidationPipe, type UploadedFile as ValidatedFile } from '@modules/shared/infrastructure/pipes/file-validation.pipe';
|
||||
import { CreateListingCommand } from '../../application/commands/create-listing/create-listing.command';
|
||||
import { type CreateListingResult } from '../../application/commands/create-listing/create-listing.handler';
|
||||
import { ModerateListingCommand } from '../../application/commands/moderate-listing/moderate-listing.command';
|
||||
import { UpdateListingStatusCommand } from '../../application/commands/update-listing-status/update-listing-status.command';
|
||||
import { UploadMediaCommand } from '../../application/commands/upload-media/upload-media.command';
|
||||
import { ModerateListingCommand } from '../../application/commands/moderate-listing/moderate-listing.command';
|
||||
import { GetListingQuery } from '../../application/queries/get-listing/get-listing.query';
|
||||
import { SearchListingsQuery } from '../../application/queries/search-listings/search-listings.query';
|
||||
import { GetPendingModerationQuery } from '../../application/queries/get-pending-moderation/get-pending-moderation.query';
|
||||
import { CreateListingDto } from '../dto/create-listing.dto';
|
||||
import { UpdateListingStatusDto } from '../dto/update-listing-status.dto';
|
||||
import { ModerateListingDto } from '../dto/moderate-listing.dto';
|
||||
import { SearchListingsDto } from '../dto/search-listings.dto';
|
||||
import { type CreateListingResult } from '../../application/commands/create-listing/create-listing.handler';
|
||||
import { type PaginatedResult } from '../../domain/repositories/listing.repository';
|
||||
import { SearchListingsQuery } from '../../application/queries/search-listings/search-listings.query';
|
||||
import { type ListingDetailData, type ListingSearchItem } from '../../domain/repositories/listing-read.dto';
|
||||
import { type PaginatedResult } from '../../domain/repositories/listing.repository';
|
||||
import { type CreateListingDto } from '../dto/create-listing.dto';
|
||||
import { type ModerateListingDto } from '../dto/moderate-listing.dto';
|
||||
import { type SearchListingsDto } from '../dto/search-listings.dto';
|
||||
import { type UpdateListingStatusDto } from '../dto/update-listing-status.dto';
|
||||
|
||||
@ApiTags('listings')
|
||||
@Controller('listings')
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { PropertyType, TransactionType, Direction } from '@prisma/client';
|
||||
import { Type, Transform } from 'class-transformer';
|
||||
import {
|
||||
IsString,
|
||||
IsNumber,
|
||||
@@ -9,9 +12,6 @@ import {
|
||||
Max,
|
||||
IsArray,
|
||||
} from 'class-validator';
|
||||
import { Type, Transform } from 'class-transformer';
|
||||
import { PropertyType, TransactionType, Direction } from '@prisma/client';
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
|
||||
export class CreateListingDto {
|
||||
@ApiProperty({ enum: TransactionType, example: 'SALE', description: 'Transaction type (SALE or RENT)' })
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { IsEnum, IsNumber, IsOptional, IsString, Max, Min } from 'class-validator';
|
||||
import { Type } from 'class-transformer';
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { Type } from 'class-transformer';
|
||||
import { IsEnum, IsNumber, IsOptional, IsString, Max, Min } from 'class-validator';
|
||||
|
||||
export class ModerateListingDto {
|
||||
@ApiProperty({ enum: ['approve', 'reject'], example: 'approve', description: 'Moderation action' })
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { IsEnum, IsNumber, IsOptional, IsString, Max, Min } from 'class-validator';
|
||||
import { Transform, Type } from 'class-transformer';
|
||||
import { ListingStatus, PropertyType, TransactionType } from '@prisma/client';
|
||||
import { ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { ListingStatus, PropertyType, TransactionType } from '@prisma/client';
|
||||
import { Transform, Type } from 'class-transformer';
|
||||
import { IsEnum, IsNumber, IsOptional, IsString, Max, Min } from 'class-validator';
|
||||
|
||||
export class SearchListingsDto {
|
||||
@ApiPropertyOptional({ enum: ListingStatus, example: 'ACTIVE', description: 'Filter by listing status' })
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { IsEnum, IsOptional, IsString } from 'class-validator';
|
||||
import { ListingStatus } from '@prisma/client';
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { ListingStatus } from '@prisma/client';
|
||||
import { IsEnum, IsOptional, IsString } from 'class-validator';
|
||||
|
||||
export class UpdateListingStatusDto {
|
||||
@ApiProperty({ enum: ListingStatus, example: 'ACTIVE', description: 'New listing status' })
|
||||
|
||||
Reference in New Issue
Block a user