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
createdAtfor automatic cleanup after 90 days - Compound indexes for efficient querying
Implementation Details:
ClientErrorModulewithDatabaseModule,LoggerModule, andThrottlerModuleimportsCreateClientErrorDtowith validation (appVersion, error array, optional taskType/context)QueryClientErrorDtowith pagination, date range, and field filtersbcyip-agentheader used to identify error source
Files Modified:
src/domains/client-error/client-error.module.ts- Module declaration with dependenciessrc/domains/client-error/client-error.controller.ts- POST and GET routessrc/domains/client-error/client-error.service.ts- Business logic, indexes, CRUDsrc/domains/client-error/dto/create-client-error.dto.ts- Creation DTOsrc/domains/client-error/dto/query-client-error.dto.ts- Query/filter DTOsrc/domains/client-error/client-error.service.spec.ts- Unit testssrc/domains/client-error/client-error.controller.spec.ts- Controller tests