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:
Ho Ngoc Hai
2026-04-08 07:15:06 +07:00
parent afa70320f5
commit 2502aa69b7
239 changed files with 746 additions and 984 deletions

View File

@@ -1,6 +1,6 @@
import { type ISearchRepository, type SearchResult } from '../../domain/repositories/search.repository';
import { GeoSearchHandler } from '../queries/geo-search/geo-search.handler';
import { GeoSearchQuery } from '../queries/geo-search/geo-search.query';
import { type ISearchRepository, type SearchResult } from '../../domain/repositories/search.repository';
function createMockSearchResult(overrides?: Partial<SearchResult>): SearchResult {
return {

View File

@@ -1,7 +1,7 @@
import { type CacheService } from '@modules/shared/infrastructure/cache.service';
import { type ISearchRepository, type SearchResult } from '../../domain/repositories/search.repository';
import { SearchPropertiesHandler } from '../queries/search-properties/search-properties.handler';
import { SearchPropertiesQuery } from '../queries/search-properties/search-properties.query';
import { type ISearchRepository, type SearchResult } from '../../domain/repositories/search.repository';
import { type CacheService } from '@modules/shared/infrastructure/cache.service';
function createMockSearchResult(overrides?: Partial<SearchResult>): SearchResult {
return {

View File

@@ -1,5 +1,5 @@
import { SyncListingHandler } from '../commands/sync-listing/sync-listing.handler';
import { SyncListingCommand } from '../commands/sync-listing/sync-listing.command';
import { SyncListingHandler } from '../commands/sync-listing/sync-listing.handler';
describe('SyncListingHandler', () => {
let handler: SyncListingHandler;

View File

@@ -1,6 +1,6 @@
import { CommandHandler, type ICommandHandler } from '@nestjs/cqrs';
import { type ListingIndexerService } from '../../../infrastructure/services/listing-indexer.service';
import { ReindexAllCommand } from './reindex-all.command';
import { ListingIndexerService } from '../../../infrastructure/services/listing-indexer.service';
export interface ReindexResult {
indexed: number;

View File

@@ -1,6 +1,6 @@
import { CommandHandler, type ICommandHandler } from '@nestjs/cqrs';
import { type ListingIndexerService } from '../../../infrastructure/services/listing-indexer.service';
import { SyncListingCommand } from './sync-listing.command';
import { ListingIndexerService } from '../../../infrastructure/services/listing-indexer.service';
@CommandHandler(SyncListingCommand)
export class SyncListingHandler implements ICommandHandler<SyncListingCommand> {

View File

@@ -1,11 +1,11 @@
import { type IQueryHandler, QueryHandler } from '@nestjs/cqrs';
import { Inject } from '@nestjs/common';
import { GeoSearchQuery } from './geo-search.query';
import { type IQueryHandler, QueryHandler } from '@nestjs/cqrs';
import {
SEARCH_REPOSITORY,
type ISearchRepository,
type SearchResult,
} from '../../../domain/repositories/search.repository';
import { GeoSearchQuery } from './geo-search.query';
@QueryHandler(GeoSearchQuery)
export class GeoSearchHandler implements IQueryHandler<GeoSearchQuery> {

View File

@@ -1,12 +1,12 @@
import { type IQueryHandler, QueryHandler } from '@nestjs/cqrs';
import { Inject } from '@nestjs/common';
import { type IQueryHandler, QueryHandler } from '@nestjs/cqrs';
import { CacheService, CachePrefix, CacheTTL } from '@modules/shared/infrastructure/cache.service';
import { SearchPropertiesQuery } from './search-properties.query';
import {
SEARCH_REPOSITORY,
type ISearchRepository,
type SearchResult,
} from '../../../domain/repositories/search.repository';
import { SearchPropertiesQuery } from './search-properties.query';
@QueryHandler(SearchPropertiesQuery)
export class SearchPropertiesHandler implements IQueryHandler<SearchPropertiesQuery> {

View File

@@ -1,7 +1,7 @@
import { Injectable } from '@nestjs/common';
import { OnEvent } from '@nestjs/event-emitter';
import { LoggerService } from '@modules/shared/infrastructure/logger.service';
import { ListingIndexerService } from '../services/listing-indexer.service';
import { type LoggerService } from '@modules/shared/infrastructure/logger.service';
import { type ListingIndexerService } from '../services/listing-indexer.service';
@Injectable()
export class ListingApprovedEventHandler {

View File

@@ -1,7 +1,7 @@
import { Inject, Injectable } from '@nestjs/common';
import { Prisma } from '@prisma/client';
import { PrismaService } from '@modules/shared/infrastructure/prisma.service';
import { LoggerService } from '@modules/shared/infrastructure/logger.service';
import { type LoggerService } from '@modules/shared/infrastructure/logger.service';
import { type PrismaService } from '@modules/shared/infrastructure/prisma.service';
import {
SEARCH_REPOSITORY,
type ISearchRepository,

View File

@@ -1,6 +1,6 @@
import { Injectable, type OnModuleInit } from '@nestjs/common';
import { LoggerService } from '@modules/shared/infrastructure/logger.service';
import { Client as TypesenseClient } from 'typesense';
import { type LoggerService } from '@modules/shared/infrastructure/logger.service';
@Injectable()
export class TypesenseClientService implements OnModuleInit {

View File

@@ -1,14 +1,14 @@
import { Injectable } from '@nestjs/common';
import { LoggerService } from '@modules/shared/infrastructure/logger.service';
import { type Client as TypesenseClient } from 'typesense';
import type { CollectionCreateSchema } from 'typesense/lib/Typesense/Collections';
import { type LoggerService } from '@modules/shared/infrastructure/logger.service';
import {
type ISearchRepository,
type ListingDocument,
type SearchParams,
type SearchResult,
} from '../../domain/repositories/search.repository';
import { TypesenseClientService } from './typesense-client.service';
import { Client as TypesenseClient } from 'typesense';
import type { CollectionCreateSchema } from 'typesense/lib/Typesense/Collections';
import { type TypesenseClientService } from './typesense-client.service';
const COLLECTION_NAME = 'listings';

View File

@@ -5,23 +5,23 @@ import {
Query,
UseGuards,
} from '@nestjs/common';
import { type CommandBus, type QueryBus } from '@nestjs/cqrs';
import {
ApiTags,
ApiOperation,
ApiResponse,
ApiBearerAuth,
} from '@nestjs/swagger';
import { CommandBus, QueryBus } from '@nestjs/cqrs';
import { SearchPropertiesQuery } from '../../application/queries/search-properties/search-properties.query';
import { GeoSearchQuery } from '../../application/queries/geo-search/geo-search.query';
import { ReindexAllCommand } from '../../application/commands/reindex-all/reindex-all.command';
import { SearchPropertiesDto } from '../dto/search-properties.dto';
import { GeoSearchDto } from '../dto/geo-search.dto';
import { Roles } from '@modules/auth/presentation/decorators/roles.decorator';
import { JwtAuthGuard } from '@modules/auth/presentation/guards/jwt-auth.guard';
import { RolesGuard } from '@modules/auth/presentation/guards/roles.guard';
import { Roles } from '@modules/auth/presentation/decorators/roles.decorator';
import { type SearchResult } from '../../domain/repositories/search.repository';
import { ReindexAllCommand } from '../../application/commands/reindex-all/reindex-all.command';
import { type ReindexResult } from '../../application/commands/reindex-all/reindex-all.handler';
import { GeoSearchQuery } from '../../application/queries/geo-search/geo-search.query';
import { SearchPropertiesQuery } from '../../application/queries/search-properties/search-properties.query';
import { type SearchResult } from '../../domain/repositories/search.repository';
import { type GeoSearchDto } from '../dto/geo-search.dto';
import { type SearchPropertiesDto } from '../dto/search-properties.dto';
@ApiTags('search')
@Controller('search')

View File

@@ -1,3 +1,5 @@
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Transform, Type } from 'class-transformer';
import {
IsOptional,
IsString,
@@ -7,8 +9,6 @@ import {
Min,
Max,
} from 'class-validator';
import { Transform, Type } from 'class-transformer';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
export enum GeoSortByOption {
DISTANCE = 'distance',

View File

@@ -1,3 +1,5 @@
import { ApiPropertyOptional } from '@nestjs/swagger';
import { Transform, Type } from 'class-transformer';
import {
IsOptional,
IsString,
@@ -7,8 +9,6 @@ import {
Min,
Max,
} from 'class-validator';
import { Transform, Type } from 'class-transformer';
import { ApiPropertyOptional } from '@nestjs/swagger';
export enum SortByOption {
PRICE_ASC = 'price_asc',

View File

@@ -1,26 +1,17 @@
import { Module, type OnModuleInit } from '@nestjs/common';
import { CqrsModule } from '@nestjs/cqrs';
// Domain
import { type LoggerService } from '@modules/shared/infrastructure/logger.service';
import { ReindexAllHandler } from './application/commands/reindex-all/reindex-all.handler';
import { SyncListingHandler } from './application/commands/sync-listing/sync-listing.handler';
import { GeoSearchHandler } from './application/queries/geo-search/geo-search.handler';
import { SearchPropertiesHandler } from './application/queries/search-properties/search-properties.handler';
import { SEARCH_REPOSITORY } from './domain/repositories/search.repository';
// Infrastructure
import { ListingApprovedEventHandler } from './infrastructure/event-handlers/listing-approved.handler';
import { ListingIndexerService } from './infrastructure/services/listing-indexer.service';
import { TypesenseClientService } from './infrastructure/services/typesense-client.service';
import { TypesenseSearchRepository } from './infrastructure/services/typesense-search.repository';
import { ListingIndexerService } from './infrastructure/services/listing-indexer.service';
import { ListingApprovedEventHandler } from './infrastructure/event-handlers/listing-approved.handler';
// Application
import { SyncListingHandler } from './application/commands/sync-listing/sync-listing.handler';
import { ReindexAllHandler } from './application/commands/reindex-all/reindex-all.handler';
import { SearchPropertiesHandler } from './application/queries/search-properties/search-properties.handler';
import { GeoSearchHandler } from './application/queries/geo-search/geo-search.handler';
// Presentation
import { SearchController } from './presentation/controllers/search.controller';
import { LoggerService } from '@modules/shared/infrastructure/logger.service';
const CommandHandlers = [SyncListingHandler, ReindexAllHandler];
const QueryHandlers = [SearchPropertiesHandler, GeoSearchHandler];