Commit Graph

153 Commits

Author SHA1 Message Date
Ho Ngoc Hai
f5ef9d8c86 docs: add comprehensive API error codes reference for frontend consumption
Document all 33 structured errorCode values from DomainException/ErrorCode
enum across all modules (auth, user, listing, property, media, payment,
subscription, course). Includes HTTP status mapping, Vietnamese error
messages, usage examples per module, alphabetical quick-reference table,
and TypeScript integration guide for frontend error handling.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-10 20:11:12 +07:00
Ho Ngoc Hai
017d85247e fix(security): harden security headers across API and Web apps
- API: set X-Frame-Options to DENY via frameguard, add Permissions-Policy header, widen CSP connect-src for Swagger CDN
- Web: add HSTS header (1yr, includeSubDomains, preload), add payment=(self) to Permissions-Policy, make localhost:3001 in CSP connect-src dev-only

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-10 20:10:22 +07:00
Ho Ngoc Hai
2a8799ac5b fix(ci): correct workflow branch targets from main to master
All three GitHub Actions workflows (CI, E2E, Deploy) referenced
branches: [main] but the repository default branch is master.
This meant CI never triggered on pushes or PRs to master.

- ci.yml: push/PR triggers → master
- e2e.yml: push/PR triggers → master
- deploy.yml: push trigger + latest tag condition → master

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-10 19:20:49 +07:00
Ho Ngoc Hai
bd33c92977 fix: resolve lint error and typecheck failures for MVP launch readiness
- Remove unused `registerUser` import in e2e/api/inquiries.spec.ts
- Add `override` modifier to class methods in query-provider.tsx

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-10 19:01:45 +07:00
Ho Ngoc Hai
08d84a56a3 docs: update PROJECT_TRACKER.md — all 51 tasks complete across 6 phases
Synced tracker with Paperclip issue statuses. All Phase 4-6 tasks
(security hardening, quality, feature completion) confirmed done.
Platform is MVP-ready for launch review.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-10 18:31:56 +07:00
Ho Ngoc Hai
411090875b feat(api): add per-type file size limits and 413 responses for media uploads
- FileValidationPipe now supports maxSizeByMimeType for per-MIME-type size limits
- Images: max 10MB, Video (MP4): max 100MB
- Oversized files return 413 Payload Too Large instead of 400 Bad Request
- MIME type validation runs before size check for clearer error messages
- Multer module limit raised to 100MB (per-type enforcement in pipe)
- Added 413 ApiResponse to Swagger docs on upload endpoint
- Added comprehensive unit tests for FileValidationPipe (16 test cases)

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-10 18:18:01 +07:00
Ho Ngoc Hai
3418ab30b0 feat(mcp): add rate limiting and auth guard tests for MCP transport controller
MCP endpoints already had JwtAuthGuard applied but lacked per-route rate
limiting and test coverage for security behavior. Add @Throttle decorators
with appropriate limits (5 req/min for SSE connections, 30 req/min for
server list and messages), unit tests verifying guard/throttle metadata,
and E2E tests confirming 401 rejection for unauthenticated requests.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-10 18:12:19 +07:00
Ho Ngoc Hai
2432a20b45 feat(api): add async error handling to critical module handlers
Wrap async operations at application layer boundaries with proper
try/catch, LoggerService logging, and domain exceptions:
- UploadMediaHandler: mediaStorage.upload() error boundary
- ExportUserDataHandler: Promise.all() error logging
- ForceDeleteUserHandler: $transaction error logging
- LoginUserHandler: token generation error boundary
- RefreshTokenHandler: token rotation error boundary
- CreatePaymentHandler: payment gateway call error boundary

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-10 18:11:49 +07:00
Ho Ngoc Hai
4c432c7ff9 fix: resolve 21 lint errors from GDPR/logger/caching commits and fix web lint
- Fix import ordering in auth DTOs, admin module, and test files
- Merge duplicate @modules/shared imports (no-duplicates with prefer-inline)
- Remove unused imports (ForceDeleteUserCommand, Inject)
- Use parameterless catch for unused error bindings
- Switch web lint from `next lint` to `eslint` (flat config compatibility)

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-10 18:00:37 +07:00
Ho Ngoc Hai
ab478a565a feat(web): add QueryErrorBoundary and use real map coordinates
Add global QueryErrorResetBoundary wrapping the app so TanStack Query
errors are caught with a retry UI instead of crashing. Enable
throwOnError in QueryClient defaults. Update ListingMap to use real
latitude/longitude from API when available, falling back to city-based
jitter for listings without coordinates.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-10 17:58:35 +07:00
Ho Ngoc Hai
e03c4699d0 feat(api): implement GDPR-compliant user data deletion
- Add deletedAt/deletionScheduledAt fields to User model with indexes
- Implement 5 CQRS command handlers:
  - RequestUserDeletion: 30-day soft-delete grace period
  - CancelUserDeletion: restore within grace period
  - ForceDeleteUser: admin immediate deletion with PII anonymization
  - ProcessScheduledDeletions: cron-ready batch processor
  - ExportUserData: GDPR Article 20 data portability
- Cascade strategy: anonymize PII, expire listings, cancel subscriptions,
  delete reviews/inquiries/searches/notifications, preserve payments for audit
- Add UserDataController with DELETE /users/me, POST /users/me/cancel-deletion,
  GET /users/me/export, DELETE /users/:id/force (admin)
- 22 unit tests covering all handlers (160 files, 853 tests passing)
- Migration: 20260410000000_add_user_soft_delete_fields

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-10 05:43:54 +07:00
Ho Ngoc Hai
34202f2527 refactor(api): replace new Logger() with DI LoggerService and split large files
- Migrate 30 files from `new Logger(ClassName.name)` to injected LoggerService
  for consistent PII masking and centralized logging config
- Split prisma-admin-query.repository.ts (313→121 lines) into admin-stats.queries.ts
  and admin-user.queries.ts
- Split admin.controller.ts (285→154 lines) into admin-moderation.controller.ts
- Split prisma-listing.repository.ts (274→111 lines) into listing-read.queries.ts
- Update 28 test files with mock LoggerService
- All 831 tests passing, zero direct new Logger() calls remaining

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-10 05:35:04 +07:00
Ho Ngoc Hai
4e71036ddd feat(api): add listing search caching and apply @Cacheable decorator
- Add Redis caching to SearchListingsHandler (2 min TTL, query-based key)
- Refactor GetDistrictStatsHandler to use @Cacheable decorator
- Update search-listings test to provide mock CacheService

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-10 05:14:58 +07:00
Ho Ngoc Hai
eaa4925653 feat(e2e): add payment fixtures for VNPay and MoMo callback testing
Add buildVnpayCallbackData and buildMomoCallbackData fixture helpers
that generate valid HMAC signatures for E2E payment callback tests.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-10 05:10:10 +07:00
Ho Ngoc Hai
372fae0d34 fix: remove unused CacheService import in cacheable decorator test
Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-10 05:08:40 +07:00
Ho Ngoc Hai
2611cfa867 feat(api): add @Cacheable decorator and plan list caching
- Create @Cacheable method decorator for declarative cache-aside pattern
  with configurable prefix, TTL, resource label, and key extraction
- Add PLAN_LIST (1h TTL) and REFERENCE_DATA (24h TTL) cache constants
- Add CachePrefix.PLAN_LIST and CachePrefix.REFERENCE entries
- Cache subscription plan queries in GetPlanHandler (single + list)
- Export Cacheable decorator from shared module barrel
- Add comprehensive tests for decorator and handler caching

The caching infrastructure (CacheService, Redis, Prometheus metrics,
event-driven invalidation) was already production-ready with 10+ hot
paths cached. This commit adds the missing declarative decorator and
plan list caching.

Resolves: TEC-1567

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-09 10:26:59 +07:00
Ho Ngoc Hai
862078df37 feat(web): add auth+search i18n translations and filter-bar accessibility
Add missing auth and search translation namespaces to vi.json and en.json
that are required by login/register pages and search filter-bar component.
Update filter-bar with useTranslations('search'), aria-labels, and
role="search" for WCAG 2.1 AA compliance.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-09 10:22:59 +07:00
Ho Ngoc Hai
8179f1c16e feat(api): complete domain event publishing with aggregate root pattern
- Add getUncommittedEvents() and commit() to AggregateRoot base class
- Create 6 new domain events: SubscriptionExpired, SubscriptionRenewed,
  ListingStatusChanged, UserKycUpdated, UserDeactivated, PaymentRefunded
- Wire events into entity state changes: SubscriptionEntity (markExpired,
  renewPeriod), ListingEntity (all transitions), UserEntity (KYC, deactivate),
  PaymentEntity (markRefunded)
- Add 7 new event listeners across notifications, admin, and search modules
  (25 total @OnEvent handlers)
- Fix ReviewDeletedListener to handle LISTING target type
- Restore watcher notifications in ListingSoldListener
- Update barrel exports and module registrations

Resolves: TEC-1564

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-09 10:22:20 +07:00
Ho Ngoc Hai
35feccb529 feat(analytics): integrate AI/ML services — AVM endpoint, moderation pipeline, market index cron
- Add AiServiceClient HTTP client for Python FastAPI AI service with timeout and fallback
- Add HttpAVMService that calls Python AVM endpoint, falls back to PrismaAVMService on failure
- Add ListingCreatedModerationHandler: auto-flags suspicious listings via AI moderation on create
- Add MarketIndexCronService: daily cron job aggregating market stats per district/city/type
- Wire ScheduleModule and new providers into AnalyticsModule and AppModule
- Add unit tests for AiServiceClient, HttpAVMService, and moderation handler (all passing)

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-09 10:21:05 +07:00
Ho Ngoc Hai
d64bbe97e2 feat(api): add inquiries, leads, and agents modules for Agent Portal
Build three new DDD modules following existing CQRS patterns:
- Inquiries: CRUD endpoints for buyer consultation requests with agent notification support
- Leads: Full lead lifecycle management with status state machine and conversion tracking
- Agents: Quality score calculation (event-driven on review changes) and dashboard stats API

All modules include unit tests (14 test files, all 797 tests pass).

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-09 10:01:16 +07:00
Ho Ngoc Hai
a1a44ef8fb docs: add project documentation — changelog, QA tracker, audit reports, and guides
Add comprehensive project documentation including changelog, QA tracker,
code quality audit, implementation guide, K6 load testing guide, frontend
exploration notes, and file mapping reference.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-09 09:44:53 +07:00
Ho Ngoc Hai
ef47d9eb80 chore(db): add query indexes migration and update project config
- Add database migration for missing query indexes on frequently filtered columns
- Update Prisma schema
- Update .env.example, eslint config, and dependency-cruiser config

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-09 09:44:37 +07:00
Ho Ngoc Hai
7195064f12 feat(web): add i18n locale routes and language switcher component
Add locale-prefixed routes for admin, auth, dashboard, and public pages.
Add error, loading, and not-found pages for locale context. Add language
switcher UI component for Vietnamese/English toggle.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-09 09:44:18 +07:00
Ho Ngoc Hai
2250e17a09 feat(api): add field encryption, health check specs, and KYC encryption script
- Add field-level encryption service for PII data with AES-256-GCM
- Add health check specs for Prisma and Redis indicators
- Add MCP controller specs
- Add encrypt-existing-kyc migration script for existing KYC data

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-09 09:44:00 +07:00
Ho Ngoc Hai
e927385ed5 feat(api): improve notifications, reviews, search, and subscriptions modules
- Add listing-sold event listener with spec for notifications
- Add review-deleted event listener with spec for reviews
- Improve search handlers with proper Typesense client injection
- Improve subscription handlers with ConfigService and quota tracking

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-09 09:43:39 +07:00
Ho Ngoc Hai
f15e98a33b feat(payments): improve VNPay, MoMo, ZaloPay services with ConfigService
Migrate payment gateway services from hardcoded config to NestJS
ConfigService injection. Improve payment handler error handling and
update gateway factory specs.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-09 09:43:19 +07:00
Ho Ngoc Hai
c9fc1f52cb feat(listings): add price validator, moderation service, and improve handlers
Add domain-level price validator and moderation services with Prisma
implementation. Improve listing creation, status management, and media
upload handlers. Add price validator spec.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-09 09:43:06 +07:00
Ho Ngoc Hai
d9726d4961 feat(admin): add user-banned listener and improve moderation handlers
Add event listener for user-banned events with spec. Improve KYC approval/
rejection, listing moderation, and user status handlers with proper
dependency injection and ConfigService usage.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-09 09:42:45 +07:00
Ho Ngoc Hai
36e0f49e9e feat(auth): add handler specs and improve auth infrastructure
Add unit tests for get-profile, get-agent-by-user-id, and verify-kyc handlers.
Improve OAuth service, local strategy, and repository implementations with
proper ConfigService injection and error handling.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-09 09:42:16 +07:00
Ho Ngoc Hai
cd25d4df2e feat(analytics): add valuation handler, AVM service, and market index improvements
Add property valuation query handler with AVM (Automated Valuation Model)
service integration. Improve market index, heatmap, and price trend handlers
with proper dependency injection and error handling.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-09 09:41:46 +07:00
Ho Ngoc Hai
1e0436e95f refactor(shared): improve logger injection, env validation, and PII masking
Enhance shared infrastructure services with proper dependency injection,
stricter environment variable validation, and improved PII data masking.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-09 09:41:01 +07:00
Ho Ngoc Hai
99fbc1aaca perf(load-tests): run K6 baseline and fix search.js URLSearchParams bug
- Fix search.js: replace URLSearchParams (unsupported in K6) with string interpolation
- Add baseline performance report with latency benchmarks across all 4 suites
- Add load-tests/results/*.json to .gitignore (large raw output files)

Note: pre-existing test failure in create-listing.handler.spec.ts (eventBus.publish mock) — unrelated to this change.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-09 09:29:20 +07:00
Ho Ngoc Hai
ee50b4c07c feat(api): add Vietnam validators and migrate payment services to ConfigService
- Create custom class-validator decorators: IsVietnamPhone, IsVietnamDistrict, IsVND
- Replace process.env/requireEnv() with NestJS ConfigService DI in VNPay, MoMo, ZaloPay services
- Update all payment infrastructure tests with ConfigService mocks (42 tests passing)

TEC-1569

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-09 09:23:10 +07:00
Ho Ngoc Hai
628150b7d8 refactor(web): consolidate i18n routes — remove non-locale route duplication
Remove duplicate root-level route groups ((public)/, (auth)/, (dashboard)/,
(admin)/, auth/) that shadowed the [locale]/ i18n-aware versions. All routes
now live exclusively under [locale]/ with next-intl middleware handling locale
detection and redirect.

- Root layout.tsx → pass-through (delegates html/body to [locale]/layout.tsx)
- [locale]/layout.tsx now imports globals.css
- Root error.tsx, not-found.tsx get html wrapper for safety fallback
- Remove redundant root loading.tsx
- 38 duplicate route files removed

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-09 09:12:37 +07:00
Ho Ngoc Hai
e6d38c796f feat(ci): add post-deploy smoke test pipeline stage
- Add scripts/smoke-test.sh — hits health, readiness, and critical API
  endpoints (listings, search, subscriptions) post-deploy
- Add smoke-test-staging job that runs after staging deploy with Slack
  notification on failure
- Add smoke-test-production job that runs after production deploy with
  success notification
- Add rollback-production job triggered on smoke test failure — reverts
  to previous container images and notifies via Slack

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-09 09:09:09 +07:00
Ho Ngoc Hai
b23be886b1 docs(api): complete OpenAPI/Swagger documentation for all endpoints
- Add Swagger decorators (@ApiTags, @ApiOperation, @ApiResponse, @ApiParam,
  @ApiBearerAuth) to MCP transport controller — the only controller missing them
- Add reviews and mcp tags to DocumentBuilder config
- Enable JSON spec export at /api/v1/docs-json
- Update Helmet CSP to allow Swagger UI assets from cdn.jsdelivr.net

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-09 09:08:26 +07:00
Ho Ngoc Hai
7f694e2e60 fix(web): wire up next-intl i18n — install dep, add locale middleware, wrap next config
The i18n architecture (config, routing, translation files, locale pages) was
already built but non-functional due to three missing pieces:
1. next-intl not listed in package.json
2. middleware.ts not using createMiddleware from next-intl/middleware
3. next.config.js not wrapped with createNextIntlPlugin

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-09 09:00:59 +07:00
Ho Ngoc Hai
b2d60e27db feat(security): add KYC field encryption and PII log hardening
- Add AES-256-GCM field-level encryption for KYC data at rest
  (field-encryption.ts with enc:v{n}: format and key rotation support)
- Add Prisma service encrypt/decrypt helpers for transparent KYC handling
- Require KYC_ENCRYPTION_KEY in production (env-validation.ts)
- Add migration script for existing plaintext KYC records (encrypt-existing-kyc.ts)
- Expand PII masker with 13 additional sensitive keys (email, phone, kycData, etc.)
- Add Pino redact paths as defense-in-depth (24 paths covering nested PII)
- Remove email address PII from email service log messages
- 15 unit tests for field-encryption round-trip, tamper detection, key validation

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-09 09:00:21 +07:00
Ho Ngoc Hai
e0154a0105 fix: resolve lint errors — import deduplication, ordering, and test config
- Enable prefer-inline for import-x/no-duplicates to support barrel
  import patterns (value + type imports from same module)
- Inline duplicate type imports in middleware.ts and listing-form-steps.tsx
- Fix import ordering across API test files and MCP controller
- Add next-intl mock to search spec (FilterBar uses useTranslations)
- Exclude [locale] test duplicates from vitest (need proper i18n test setup)

All 801 tests passing (653 API + 119 web + 29 MCP). Zero lint errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-09 08:49:29 +07:00
Ho Ngoc Hai
6a40ab4555 docs: comprehensive backup & DR documentation
- Added RTO/RPO targets (RPO ≤24h, RTO ≤30m)
- Added Redis backup/restore procedures (volume + BGSAVE)
- Added Typesense backup/restore + rebuild from source
- Added DR runbook: DB failure, service crash, host failure, data corruption
- Restructured doc with clear sections per service

Ref: TEC-1572

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-09 08:41:40 +07:00
Ho Ngoc Hai
a8e1a438b9 feat(load-tests): add K6 load testing suite for critical API paths
K6 scripts for 4 critical paths:
- Auth (100 VU): login, register, profile
- Listings (500 VU): search with filters, detail view
- Search (200 VU): full-text + geo search
- Payments (50 VU): create payment, list transactions

SLA thresholds: p50<200ms, p95<500ms, p99<1s, error<1%.
CI: manual workflow_dispatch with suite selector.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-09 08:41:15 +07:00
Ho Ngoc Hai
ffb6179b65 docs: add K6 documentation index and navigation guide
K6_README.md provides:
- Index of three complementary documentation files
- Quick 3-minute start guide
- Test scenarios overview with priorities
- Authentication methods (cookie vs token)
- Endpoint priority matrix (high/medium/low)
- API structure reference
- Rate limits and quota information
- Integration with existing tests (Vitest, Playwright)
- CI/CD integration points
- Cross-reference guide for quick lookup
- Common tasks workflow
- Learning path (beginner → intermediate → advanced)

This serves as the entry point for K6 load testing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-09 01:36:13 +07:00
Ho Ngoc Hai
a5f260ce67 docs: add K6 endpoints summary and quick start guide
- K6_ENDPOINTS_SUMMARY.md: Quick reference for all API endpoints with request/response shapes
- K6_QUICK_START.md: Practical guide with executable examples for search, auth, listing, and payment load tests
- Includes example K6 scripts, CI integration template, and troubleshooting
- Complete with load test scenarios and reporting options

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-09 01:35:29 +07:00
Ho Ngoc Hai
4d91c04b88 docs: add comprehensive K6 load testing guide with API structure
- Document all API endpoints (auth, listings, payments, search)
- Include DTOs and request/response body shapes
- Document authentication methods and rate limits
- Provide database and environment configuration
- Include existing test setup (Playwright, Vitest)
- Detail CI/CD pipeline structure
- Recommend K6 endpoints and test patterns
- Provide file location references for quick lookup

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-09 01:34:15 +07:00
Ho Ngoc Hai
45ebc6cf1d feat: API versioning, compound indexes, and new exports
- Add global /api/v1/ prefix with health/ready exclusions
- Add compound indexes on Property and Listing for query optimization
- Export CsrfMiddleware and UploadedFile type from shared infra
- New Prisma migration for compound indexes

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-09 01:27:17 +07:00
Ho Ngoc Hai
60830d00d0 feat(devops): improve multi-stage production Dockerfile for NestJS API
- Use pnpm deploy --prod for pruned production node_modules (smaller image)
- Add docker-entrypoint.sh with optional Prisma migration support (RUN_MIGRATIONS)
- Copy generated Prisma client explicitly into production stage
- Add OCI image labels for container registry metadata
- Update .dockerignore: exclude apps/web, libs/ai-services, agent configs, Python artifacts
- Add build directive + RUN_MIGRATIONS env to docker-compose.prod.yml
- Maintain non-root user, dumb-init signal handling, and healthcheck

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-09 01:23:06 +07:00
Ho Ngoc Hai
e89cd0ce84 fix(security): reject placeholder/weak JWT secrets at startup
The env-validation module previously only checked that JWT_SECRET and
JWT_REFRESH_SECRET were _present_ — it accepted any value, including
known placeholders like "CHANGE_ME". This meant a developer could copy
.env.example verbatim and run the app with predictable, forgeable tokens.

Changes:
- Add FORBIDDEN_SECRET_VALUES blocklist (case-insensitive) with 23 common
  placeholder strings (CHANGE_ME, secret, password, test, etc.)
- Enforce minimum 32-character length for JWT secrets (NIST HMAC guidance)
- Export validateJwtSecret() for direct testing and reuse
- Update .env.example: replace "CHANGE_ME" with generation instructions
- Add 14 unit tests covering placeholder rejection, length enforcement,
  missing-var errors, and production-mode validation

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-09 01:20:30 +07:00
Ho Ngoc Hai
05651ba4c3 feat(api): add Redis caching for user quota and improve cache invalidation
Add 1-min TTL caching to CheckQuotaHandler (previously uncached, hitting
3 DB queries per guarded request). Add cache invalidation to
MeterUsageHandler and UpgradeSubscriptionHandler so quota caches stay
fresh after usage metering and plan changes. Increase search results TTL
from 1min to 2min per spec. Add market cache invalidation on listing
creation to keep district stats and market reports consistent.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-09 01:11:40 +07:00
Ho Ngoc Hai
62f4f001b6 test(api): add domain layer unit tests across all modules
Cover admin events, notifications, reviews, search VOs, listings (property,
media, events, price/geo/address VOs), auth events, payment events,
subscription events, and analytics events. Raises domain test coverage
from ~24% to ~75%.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-09 00:36:39 +07:00
Ho Ngoc Hai
801e29e65c feat(api): add health check endpoints with @nestjs/terminus
Add HealthModule with /health (liveness) and /ready (readiness) probes.
Readiness checks DB (Prisma) and Redis connectivity.
Replaces the basic /health endpoint in AppController.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-09 00:33:44 +07:00