fix(api,ci): remove type-only imports for DI and isolate CI ports from dev

- Remove `type` keyword from NestJS injectable class imports across all
  modules to fix runtime DI resolution (330+ handler/listener files)
- Offset CI docker-compose ports (5433/6380/8109/9002) to avoid
  conflicts with running dev containers
- Update .env.test, playwright.config.ts, and e2e workflow to use
  isolated CI ports with configurable overrides
- Fix prisma/seed.ts to use deterministic IDs for Prisma 7 upsert
  compatibility (phoneHash replaced phone as unique index)
- Add dedicated Docker bridge network for CI service containers

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ho Ngoc Hai
2026-04-13 01:40:14 +07:00
parent 1617921993
commit 25420720e7
345 changed files with 3266 additions and 924 deletions

View File

@@ -1,5 +1,5 @@
import { BaseEntity } from './base-entity';
import { type DomainEvent } from './domain-event';
import { DomainEvent } from './domain-event';
export abstract class AggregateRoot<TId = string> extends BaseEntity<TId> {
private _domainEvents: DomainEvent[] = [];

View File

@@ -1,4 +1,4 @@
import { Injectable, type OnModuleInit } from '@nestjs/common';
import { Injectable, OnModuleInit } from '@nestjs/common';
import { InjectMetric } from '@willsoto/nestjs-prometheus';
// eslint-disable-next-line @typescript-eslint/consistent-type-imports -- NestJS DI requires value imports for emitDecoratorMetadata
import { Counter } from 'prom-client';

View File

@@ -1,4 +1,4 @@
import { type CachePrefix, CacheService, type CacheTTL } from '../cache.service';
import { CachePrefix, CacheService, CacheTTL } from '../cache.service';
/**
* Metadata key for @Cacheable decorator options.

View File

@@ -1,6 +1,6 @@
import { SetMetadata } from '@nestjs/common';
import { type UserRole } from '@prisma/client';
import { USER_RATE_LIMIT_KEY, type UserRateLimitOptions } from '../guards/user-rate-limit.guard';
import { UserRole } from '@prisma/client';
import { USER_RATE_LIMIT_KEY, UserRateLimitOptions } from '../guards/user-rate-limit.guard';
/**
* Decorator to override per-user rate limits for a specific route or controller.

View File

@@ -12,7 +12,7 @@
import { Prisma } from '@prisma/client';
import {
type FieldEncryptionService,
FieldEncryptionService,
type ModelEncryptionConfig,
type ModelEncryptionFieldConfig,
} from './field-encryption.service';

View File

@@ -1,7 +1,7 @@
import { Injectable } from '@nestjs/common';
// eslint-disable-next-line @typescript-eslint/consistent-type-imports -- NestJS DI requires value imports
import { EventEmitter2 } from '@nestjs/event-emitter';
import { type DomainEvent } from '../domain/domain-event';
import { DomainEvent } from '../domain/domain-event';
@Injectable()
export class EventBusService {

View File

@@ -16,7 +16,7 @@ import {
isEncrypted,
type FieldEncryptionConfig,
} from './field-encryption';
import { type LoggerService } from './logger.service';
import { LoggerService } from './logger.service';
// ---------------------------------------------------------------------------
// Configuration types

View File

@@ -1,15 +1,15 @@
import {
type ArgumentsHost,
Catch,
type ExceptionFilter,
ExceptionFilter,
HttpException,
HttpStatus,
} from '@nestjs/common';
import { Prisma } from '@prisma/client';
import { type Request, type Response } from 'express';
import { DomainException, type ErrorResponseBody } from '../../domain/domain-exception';
import { Request, Response } from 'express';
import { DomainException, ErrorResponseBody } from '../../domain/domain-exception';
import { ErrorCode } from '../../domain/error-codes';
import { type LoggerService } from '../logger.service';
import { LoggerService } from '../logger.service';
@Catch()
export class GlobalExceptionFilter implements ExceptionFilter {

View File

@@ -5,14 +5,14 @@ import {
HttpException,
HttpStatus,
} from '@nestjs/common';
import { type Reflector } from '@nestjs/core';
import { type Request, type Response } from 'express';
import { Reflector } from '@nestjs/core';
import { Request, Response } from 'express';
import {
ENDPOINT_RATE_LIMIT_KEY,
type EndpointRateLimitOptions,
} from '../decorators/endpoint-rate-limit.decorator';
import { type LoggerService } from '../logger.service';
import { type RedisService } from '../redis.service';
import { LoggerService } from '../logger.service';
import { RedisService } from '../redis.service';
/** Express request extended with optional JWT user payload. */
interface AuthenticatedRequest extends Request {

View File

@@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common';
import { ThrottlerGuard } from '@nestjs/throttler';
import { type Request } from 'express';
import { Request } from 'express';
/**
* Extends ThrottlerGuard to extract real client IP behind reverse proxies

View File

@@ -5,10 +5,10 @@ import {
HttpException,
HttpStatus,
} from '@nestjs/common';
import { type Reflector } from '@nestjs/core';
import { type UserRole } from '@prisma/client';
import { type LoggerService } from '../logger.service';
import { type RedisService } from '../redis.service';
import { Reflector } from '@nestjs/core';
import { UserRole } from '@prisma/client';
import { LoggerService } from '../logger.service';
import { RedisService } from '../redis.service';
/**
* Role-based rate limits (requests per window).

View File

@@ -1,5 +1,5 @@
import { Injectable, type LoggerService as NestLoggerService } from '@nestjs/common';
import pinoLogger, { type Logger, stdTimeFunctions } from 'pino';
import { Injectable, LoggerService as NestLoggerService } from '@nestjs/common';
import pinoLogger, { Logger, stdTimeFunctions } from 'pino';
import { maskPii } from './pii-masker';
@Injectable()

View File

@@ -1,6 +1,6 @@
import { randomUUID } from 'node:crypto';
import { Injectable, type NestMiddleware } from '@nestjs/common';
import { type NextFunction, type Request, type Response } from 'express';
import { Injectable, NestMiddleware } from '@nestjs/common';
import { NextFunction, Request, Response } from 'express';
const CORRELATION_ID_HEADER = 'x-correlation-id';

View File

@@ -1,6 +1,6 @@
import { randomBytes } from 'node:crypto';
import { ForbiddenException, Injectable, type NestMiddleware } from '@nestjs/common';
import { type NextFunction, type Request, type Response } from 'express';
import { ForbiddenException, Injectable, NestMiddleware } from '@nestjs/common';
import { NextFunction, Request, Response } from 'express';
const CSRF_COOKIE = 'XSRF-TOKEN';
const CSRF_HEADER = 'x-csrf-token';

View File

@@ -1,6 +1,6 @@
import { Injectable, type NestMiddleware } from '@nestjs/common';
import { type NextFunction, type Request, type Response } from 'express';
import { type LoggerService } from '../logger.service';
import { Injectable, NestMiddleware } from '@nestjs/common';
import { NextFunction, Request, Response } from 'express';
import { LoggerService } from '../logger.service';
@Injectable()
export class RequestLoggingMiddleware implements NestMiddleware {

View File

@@ -1,5 +1,5 @@
import { Injectable, type NestMiddleware } from '@nestjs/common';
import { type NextFunction, type Request, type Response } from 'express';
import { Injectable, NestMiddleware } from '@nestjs/common';
import { NextFunction, Request, Response } from 'express';
import sanitizeHtml from 'sanitize-html';
const SANITIZE_OPTIONS: sanitizeHtml.IOptions = {

View File

@@ -1,10 +1,10 @@
import { Injectable, type OnModuleInit, type OnModuleDestroy } from '@nestjs/common';
import { Injectable, OnModuleInit, OnModuleDestroy } from '@nestjs/common';
import { PrismaPg } from '@prisma/adapter-pg';
import { PrismaClient } from '@prisma/client';
import pg from 'pg';
import { createEncryptionExtension } from './encryption-middleware';
import { FieldEncryptionService } from './field-encryption.service';
import { type LoggerService } from './logger.service';
import { LoggerService } from './logger.service';
@Injectable()
export class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy {

View File

@@ -1,4 +1,4 @@
import { Injectable, type OnModuleDestroy } from '@nestjs/common';
import { Injectable, OnModuleDestroy } from '@nestjs/common';
import Redis from 'ioredis';
/**

View File

@@ -1,4 +1,4 @@
import { Global, type MiddlewareConsumer, Module, type NestModule, RequestMethod } from '@nestjs/common';
import { Global, MiddlewareConsumer, Module, NestModule, RequestMethod } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { APP_FILTER } from '@nestjs/core';
import { EventEmitterModule } from '@nestjs/event-emitter';