Refactor research audience handling and validation
AH
4mo ago+198+198+012345678901234567890123456789-22-22-01234567890123456789
- Updated
getResearchAudienceHandlerto use the newvalidateGetResearchAudienceRequestfor request validation. - Introduced
researchAudiencePlatforms.tsto define supported audience platforms. - Added
validateGetResearchAudienceRequestto validate incoming requests for the audience endpoint, ensuring proper platform handling and defaults. - Created tests for
validateGetResearchAudienceRequestto cover various scenarios including platform validation and defaults. - Refactored
mapArtistAudienceSourceto utilize the new platform definitions.
These changes enhance the clarity and maintainability of the audience research functionality.
Summary by cubic
Centralized audience platform handling and validation. Defaults platform to instagram, rejects invalid values, and hardens mapping against prototype keys.
- Refactors
- Added
researchAudiencePlatforms.tsmapping allowed platforms to SongStats sources. - Introduced
validateGetResearchAudienceRequestto validate auth/artist andplatform; defaults toinstagramand returns 400 on invalid input. - Updated
getResearchAudienceHandlerto use the new validator andvalidated.platformin the SongStats path. - Updated
mapArtistAudienceSourceto use the shared enum andObject.hasOwnto avoid prototype keys; added tests for known/unknown platforms and prototype handling.
- Added
Summary by CodeRabbit
- Refactor
- Centralized platform validation for research audience queries with enhanced error messaging for unsupported platforms.