Skip to main content
Version: 1.1.0

feat-client-error-endpoint

✨ New Features

Client Error Reporting Endpoint

Goal: Allow front-end applications (MagicBox, Tower, etc.) to report client-side errors to the backend for centralized monitoring and debugging.

Solution: New client-errors domain with a throttled POST endpoint for error creation and a GET endpoint (admin-only) for querying errors with filters and pagination.

Features:

  • POST /client-errors — create a client error report (rate-limited: 60 req/min)
  • GET /client-errors — list/filter errors by company, user, source, date range, task type (admin only)
  • TTL index on createdAt for automatic cleanup after 90 days
  • Compound indexes for efficient querying

Implementation Details:

  • ClientErrorModule with DatabaseModule, LoggerModule, and ThrottlerModule imports
  • CreateClientErrorDto with validation (appVersion, error array, optional taskType/context)
  • QueryClientErrorDto with pagination, date range, and field filters
  • bcyip-agent header used to identify error source

Files Modified:

  • src/domains/client-error/client-error.module.ts - Module declaration with dependencies
  • src/domains/client-error/client-error.controller.ts - POST and GET routes
  • src/domains/client-error/client-error.service.ts - Business logic, indexes, CRUD
  • src/domains/client-error/dto/create-client-error.dto.ts - Creation DTO
  • src/domains/client-error/dto/query-client-error.dto.ts - Query/filter DTO
  • src/domains/client-error/client-error.service.spec.ts - Unit tests
  • src/domains/client-error/client-error.controller.spec.ts - Controller tests