@@ -9,6 +9,7 @@ import { mapPublicCreatorStats } from './creators.stats';
99import {
1010 sendSuccess ,
1111 sendValidationError ,
12+ sendNotFound ,
1213} from '../../utils/api-response.utils' ;
1314import { attachTimestampHeader } from '../../utils/timestamp-headers.utils' ;
1415import { parsePublicQuery } from '../../utils/public-query-parse.utils' ;
@@ -21,6 +22,10 @@ import {
2122 type FilterParseErrorCategory ,
2223} from '../../utils/filter-parse-metrics.utils' ;
2324import { parseCreatorId } from '../../utils/creator-id.utils' ;
25+ import {
26+ creatorProfileExists ,
27+ getCreatorProfile ,
28+ } from '../creator/creator-profile.service' ;
2429
2530/**
2631 * Controller for GET /api/v1/creators
@@ -35,16 +40,18 @@ export const httpListCreators: AsyncController = async (req, res, next) => {
3540 warnIfUnrecognizedCreatorListSort ( ctx . query , req . requestId ) ;
3641
3742 // Validate query parameters
38- const parsed = parsePublicQuery (
39- CreatorListQuerySchema ,
40- ctx . query ,
41- { debugContext : 'creator-list-query' }
42- ) ;
43+ const parsed = parsePublicQuery ( CreatorListQuerySchema , ctx . query , {
44+ debugContext : 'creator-list-query' ,
45+ } ) ;
4346 if ( ! parsed . ok ) {
4447 // Increment filter parse error counter
4548 const category = categorizeParseError ( parsed . details ) ;
4649 incrementFilterParseError ( '/api/v1/creators' , category ) ;
47- return sendValidationError ( res , 'Invalid query parameters' , parsed . details ) ;
50+ return sendValidationError (
51+ res ,
52+ 'Invalid query parameters' ,
53+ parsed . details
54+ ) ;
4855 }
4956 const validatedQuery = parsed . data ;
5057
@@ -87,7 +94,12 @@ function categorizeParseError(
8794 details : Array < { field : string ; message : string } >
8895) : FilterParseErrorCategory {
8996 // Check for unknown key errors (strict mode violations)
90- if ( details . some ( d => d . message . includes ( 'unrecognized' ) || d . message . includes ( 'unknown' ) ) ) {
97+ if (
98+ details . some (
99+ d =>
100+ d . message . includes ( 'unrecognized' ) || d . message . includes ( 'unknown' )
101+ )
102+ ) {
91103 return 'unknown_key' ;
92104 }
93105 // Default to invalid_value for type/range errors
@@ -103,7 +115,9 @@ function categorizeParseError(
103115export const httpGetCreatorStats : AsyncController = async ( req , res , next ) => {
104116 try {
105117 const rawId = req . params . id ;
106- const _creatorId = parseCreatorId ( Array . isArray ( rawId ) ? rawId [ 0 ] : rawId ) ;
118+ const _creatorId = parseCreatorId (
119+ Array . isArray ( rawId ) ? rawId [ 0 ] : rawId
120+ ) ;
107121
108122 // TODO: Fetch actual creator metrics from database/service using _creatorId
109123 // For now, return placeholder data
@@ -123,3 +137,25 @@ export const httpGetCreatorStats: AsyncController = async (req, res, next) => {
123137 next ( error ) ;
124138 }
125139} ;
140+
141+ /**
142+ * Controller for GET /api/v1/creators/:id
143+ *
144+ * Returns public profile details for a specific creator.
145+ */
146+ export const httpGetCreator : AsyncController = async ( req , res , next ) => {
147+ try {
148+ const rawId = req . params . id ;
149+ const creatorId = Array . isArray ( rawId ) ? rawId [ 0 ] : rawId ;
150+
151+ if ( ! ( await creatorProfileExists ( creatorId ) ) ) {
152+ return sendNotFound ( res , 'Creator' ) ;
153+ }
154+
155+ const profile = await getCreatorProfile ( creatorId ) ;
156+ attachTimestampHeader ( res ) ;
157+ sendSuccess ( res , profile , 200 , 'Creator retrieved successfully' ) ;
158+ } catch ( error ) {
159+ next ( error ) ;
160+ }
161+ } ;
0 commit comments