@@ -13,6 +13,38 @@ import type { BadgeParams } from '../../../types';
1313import { themes } from '../../../lib/svg/themes' ;
1414import { streakParamsSchema } from '../../../lib/validations' ;
1515
16+ /**
17+ * GET /api/streak - Returns GitHub contribution streak as SVG image
18+ *
19+ * Query Parameters:
20+ * - username (string, required): GitHub username
21+ * - theme (string, optional): 'default', 'dark', 'light' (default: 'default')
22+ * - hide_border (boolean, optional): Hide card border (default: false)
23+ * - hide_title (boolean, optional): Hide card title (default: false)
24+ * - hide_total (boolean, optional): Hide total contributions (default: false)
25+ * - count_private (boolean, optional): Include private contributions (default: false)
26+ * - show_icons (boolean, optional): Show contribution icons (default: true)
27+ * - ring_color (string, optional): Ring color hex (default: '#2c3e50')
28+ * - curr_streak_color (string, optional): Current streak text color (default: '#2c3e50')
29+ * - side_streak_color (string, optional): Longest streak text color (default: '#7f8c8d')
30+ * - curr_streak_label (string, optional): Current streak label (default: 'Current streak')
31+ * - side_streak_label (string, optional): Longest streak label (default: 'Longest streak')
32+ * - date_format (string, optional): Date format (default: 'YYYY-MM-DD')
33+ *
34+ * Response:
35+ * - 200: SVG image with Content-Type: image/svg+xml
36+ * - Cache-Control: public, max-age=3600, s-maxage=3600, stale-while-revalidate=60
37+ * - CSP: default-src 'none'; style-src 'unsafe-inline'
38+ * - 400: { "error": "Missing required parameter: username" }
39+ * - 404: { "error": "User not found or has no contributions" }
40+ * - 500: { "error": "Failed to fetch streak data" }
41+ *
42+ * Caching:
43+ * - Success: Cached 1 hour, stale-while-revalidate 60 seconds
44+ * - Errors: Not cached
45+ * - Cache key includes username and theme
46+ */
47+
1648export async function GET ( request : Request ) {
1749 const { searchParams } = new URL ( request . url ) ;
1850
0 commit comments