File tree Expand file tree Collapse file tree 4 files changed +39
-7
lines changed
Expand file tree Collapse file tree 4 files changed +39
-7
lines changed Original file line number Diff line number Diff line change 44 * Reuses shared TTLs from {@link PUBLIC_ENDPOINT_CACHE_SECONDS} where appropriate.
55 */
66import { PUBLIC_ENDPOINT_CACHE_SECONDS } from './public-endpoint-cache.constants' ;
7+ import { CREATOR_PUBLIC_ROUTE_NAMES } from './creator-public-routes.constants' ;
78
89/**
910 * Max-age (seconds) for public creator GET responses (list, profile, stats).
@@ -18,15 +19,15 @@ const publicReadSeconds = CREATOR_PUBLIC_ROUTE_CACHE_MAX_AGE_SECONDS.publicRead;
1819 * Options for {@link cacheControl} on creator public routes.
1920 */
2021export const CREATOR_PUBLIC_ROUTE_CACHE_PRESETS = {
21- creatorList : {
22+ [ CREATOR_PUBLIC_ROUTE_NAMES . LIST ] : {
2223 maxAge : publicReadSeconds ,
2324 type : 'public' as const ,
2425 } ,
25- creatorStats : {
26+ [ CREATOR_PUBLIC_ROUTE_NAMES . GET_STATS ] : {
2627 maxAge : publicReadSeconds ,
2728 type : 'public' as const ,
2829 } ,
29- creatorProfile : {
30+ [ CREATOR_PUBLIC_ROUTE_NAMES . GET_PROFILE ] : {
3031 maxAge : publicReadSeconds ,
3132 type : 'public' as const ,
3233 } ,
Original file line number Diff line number Diff line change 1+ /**
2+ * Shared route name constants for creator-facing public API endpoints.
3+ *
4+ * These constants provide stable identifiers for public creator routes,
5+ * allowing related modules (controllers, tests, client-side) to reference
6+ * routes by name instead of hardcoded strings.
7+ */
8+ export const CREATOR_PUBLIC_ROUTE_NAMES = {
9+ /** GET /api/v1/creators - Paginated list of creators */
10+ LIST : 'creators:list' ,
11+ /** GET /api/v1/creators/:creatorId/profile - Public profile details */
12+ GET_PROFILE : 'creators:profile:get' ,
13+ /** PUT /api/v1/creators/:creatorId/profile - Upsert profile (scaffold) */
14+ UPSERT_PROFILE : 'creators:profile:upsert' ,
15+ /** GET /api/v1/creators/:creatorId/stats - Public creator stats */
16+ GET_STATS : 'creators:stats:get' ,
17+ } as const ;
Original file line number Diff line number Diff line change 88import { ROOT as CREATORS_ROOT } from '../../constants/creator.constants' ;
99import { cacheControl } from '../../middlewares/cache-control.middleware' ;
1010import { CREATOR_PUBLIC_ROUTE_CACHE_PRESETS } from '../../constants/creator-public-cache.constants' ;
11+ import { CREATOR_PUBLIC_ROUTE_NAMES } from '../../constants/creator-public-routes.constants' ;
1112
1213const router = Router ( ) ;
1314
@@ -29,7 +30,7 @@ const router = Router();
2930 */
3031router . get (
3132 CREATORS_ROOT ,
32- cacheControl ( CREATOR_PUBLIC_ROUTE_CACHE_PRESETS . creatorList ) ,
33+ cacheControl ( CREATOR_PUBLIC_ROUTE_CACHE_PRESETS [ CREATOR_PUBLIC_ROUTE_NAMES . LIST ] ) ,
3334 listCreators
3435) ;
3536
@@ -40,7 +41,7 @@ router.get(
4041 */
4142router . get (
4243 '/:creatorId/profile' ,
43- cacheControl ( CREATOR_PUBLIC_ROUTE_CACHE_PRESETS . creatorProfile ) ,
44+ cacheControl ( CREATOR_PUBLIC_ROUTE_CACHE_PRESETS [ CREATOR_PUBLIC_ROUTE_NAMES . GET_PROFILE ] ) ,
4445 getCreatorProfileHandler
4546) ;
4647
Original file line number Diff line number Diff line change 11import { Router } from 'express' ;
2- import { httpListCreators } from './creators.controllers' ;
2+ import { httpListCreators , httpGetCreatorStats } from './creators.controllers' ;
33import { cacheControl } from '../../middlewares/cache-control.middleware' ;
44import { CREATOR_PUBLIC_ROUTE_CACHE_PRESETS } from '../../constants/creator-public-cache.constants' ;
5+ import { CREATOR_PUBLIC_ROUTE_NAMES } from '../../constants/creator-public-routes.constants' ;
56
67const creatorsRouter = Router ( ) ;
78
@@ -13,8 +14,20 @@ const creatorsRouter = Router();
1314 */
1415creatorsRouter . get (
1516 '/' ,
16- cacheControl ( CREATOR_PUBLIC_ROUTE_CACHE_PRESETS . creatorList ) ,
17+ cacheControl ( CREATOR_PUBLIC_ROUTE_CACHE_PRESETS [ CREATOR_PUBLIC_ROUTE_NAMES . LIST ] ) ,
1718 httpListCreators
1819) ;
1920
21+ /**
22+ * GET /api/v1/creators/:id/stats
23+ *
24+ * Get public stats for a specific creator.
25+ * Public endpoint with 5-minute cache.
26+ */
27+ creatorsRouter . get (
28+ '/:id/stats' ,
29+ cacheControl ( CREATOR_PUBLIC_ROUTE_CACHE_PRESETS [ CREATOR_PUBLIC_ROUTE_NAMES . GET_STATS ] ) ,
30+ httpGetCreatorStats
31+ ) ;
32+
2033export default creatorsRouter ;
You can’t perform that action at this time.
0 commit comments