Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | /**
* System Endpoints
* System health and monitoring endpoints
*/
import type { ApiEndpoint } from '@/types/api-docs';
export const systemEndpoints: ApiEndpoint[] = [
{
id: 'health-check',
method: 'GET',
path: '/api/health',
summary: 'Health check',
description: 'Returns system health status including database connectivity and memory usage',
category: 'system',
requiresAuth: false,
responses: [
{
status: 200,
description: 'System healthy',
example: {
status: 'healthy',
timestamp: '2024-01-01T00:00:00Z',
services: { database: 'healthy', memory: 'healthy' },
metrics: { dbLatency: 15, heapUsedMB: 256 },
},
},
{
status: 503,
description: 'System unhealthy',
example: {
status: 'unhealthy',
services: { database: 'unhealthy', memory: 'healthy' },
},
},
],
},
{
id: 'webhooks-stripe',
method: 'POST',
path: '/api/webhooks/stripe',
summary: 'Stripe webhook handler',
description: 'Processes payment events from Stripe (payment_intent.succeeded, payment_intent.payment_failed, payment_intent.canceled, charge.refunded, charge.dispute.created)',
category: 'system',
requiresAuth: false,
requestBody: {
contentType: 'application/json',
fields: [
{ name: 'type', type: 'string', required: true, description: 'Stripe event type' },
{ name: 'data', type: 'object', required: true, description: 'Event data object' },
{ name: 'id', type: 'string', required: true, description: 'Stripe event ID' },
],
},
parameters: [
{ name: 'stripe-signature', type: 'string', required: true, location: 'header', description: 'Stripe webhook signature for verification' },
],
responses: [
{ status: 200, description: 'Webhook processed successfully', example: { received: true } },
{ status: 400, description: 'Missing or invalid signature' },
{ status: 500, description: 'Webhook not configured or processing failed' },
],
},
{
id: 'cron-cleanup-logs',
method: 'POST',
path: '/api/cron/cleanup-logs',
summary: 'Cleanup old logs',
description: 'Cron job to delete old error logs (30 days) and performance metrics (7 days). Requires CRON_SECRET for authorization.',
category: 'system',
requiresAuth: false,
parameters: [
{ name: 'authorization', type: 'string', required: true, location: 'header', description: 'Bearer token with CRON_SECRET' },
],
responses: [
{
status: 200,
description: 'Cleanup completed',
example: {
success: true,
deleted: { errorLogs: 150, performanceMetrics: 500 },
},
},
{ status: 401, description: 'Invalid or missing CRON_SECRET' },
],
},
{
id: 'analytics-track',
method: 'POST',
path: '/api/analytics/track',
summary: 'Track analytics event',
description: 'Tracks user events for analytics (runs on Edge runtime)',
category: 'system',
requiresAuth: false,
requestBody: {
contentType: 'application/json',
fields: [
{ name: 'category', type: 'string', required: true, description: 'Event category (e.g., "product", "cart", "checkout")' },
{ name: 'action', type: 'string', required: true, description: 'Event action (e.g., "view", "add", "purchase")' },
{ name: 'label', type: 'string', required: false, description: 'Optional event label' },
{ name: 'value', type: 'number', required: false, description: 'Optional numeric value' },
{ name: 'timestamp', type: 'string', required: false, description: 'Event timestamp (ISO format)' },
{ name: 'userAgent', type: 'string', required: false, description: 'Browser user agent' },
{ name: 'url', type: 'string', required: false, description: 'Page URL where event occurred' },
],
example: {
category: 'product',
action: 'view',
label: 'SKU-12345',
value: 1,
timestamp: '2025-01-15T12:00:00Z',
url: '/products/12345',
},
},
responses: [
{ status: 200, description: 'Event tracked', example: { success: true, data: { tracked: true } } },
{ status: 400, description: 'Missing required fields', example: { success: false, error: { code: 'VALIDATION_ERROR', message: 'Missing required fields (category, action)' } } },
{ status: 500, description: 'Failed to track event', example: { success: false, error: { code: 'INTERNAL_ERROR', message: 'Failed to track event' } } },
],
},
// Additional Analytics Endpoints
{
id: 'analytics-ab-test',
method: 'POST',
path: '/api/analytics/ab-test',
summary: 'Track A/B test event',
description: 'Records an A/B test participation or conversion event',
category: 'analytics',
requiresAuth: false,
requestBody: {
contentType: 'application/json',
fields: [
{ name: 'testId', type: 'string', required: true, description: 'A/B test identifier' },
{ name: 'variant', type: 'string', required: true, description: 'Variant shown to user' },
{ name: 'event', type: 'string', required: true, description: 'Event type', enum: ['view', 'conversion'] },
{ name: 'sessionId', type: 'string', required: false, description: 'Session identifier' },
],
},
responses: [
{ status: 200, description: 'Event recorded' },
{ status: 400, description: 'Invalid event data' },
],
},
{
id: 'analytics-pageview',
method: 'POST',
path: '/api/analytics/pageview',
summary: 'Track pageview',
description: 'Records a pageview event for analytics',
category: 'analytics',
requiresAuth: false,
requestBody: {
contentType: 'application/json',
fields: [
{ name: 'path', type: 'string', required: true, description: 'Page path' },
{ name: 'referrer', type: 'string', required: false, description: 'Referrer URL' },
{ name: 'sessionId', type: 'string', required: false, description: 'Session identifier' },
],
},
responses: [
{ status: 200, description: 'Pageview recorded' },
],
},
{
id: 'analytics-session',
method: 'POST',
path: '/api/analytics/session',
summary: 'Track session',
description: 'Creates or updates a user session for analytics',
category: 'analytics',
requiresAuth: false,
requestBody: {
contentType: 'application/json',
fields: [
{ name: 'sessionId', type: 'string', required: true, description: 'Session identifier' },
{ name: 'event', type: 'string', required: true, description: 'Session event', enum: ['start', 'end', 'heartbeat'] },
],
},
responses: [
{ status: 200, description: 'Session updated' },
],
},
// Contact
{
id: 'contact-submit',
method: 'POST',
path: '/api/contact',
summary: 'Submit contact form',
description: 'Submits a contact form message',
category: 'public',
requiresAuth: false,
requestBody: {
contentType: 'application/json',
fields: [
{ name: 'name', type: 'string', required: true, description: 'Contact name' },
{ name: 'email', type: 'string', required: true, description: 'Contact email' },
{ name: 'subject', type: 'string', required: true, description: 'Message subject' },
{ name: 'message', type: 'string', required: true, description: 'Message content' },
],
},
responses: [
{ status: 200, description: 'Message sent successfully' },
{ status: 400, description: 'Validation failed' },
{ status: 429, description: 'Rate limit exceeded' },
],
},
// Cron Jobs
{
id: 'cron-analytics-aggregate',
method: 'POST',
path: '/api/cron/analytics-aggregate',
summary: 'Aggregate analytics data',
description: 'Aggregates raw analytics data into summary tables (called by cron)',
category: 'cron',
requiresAuth: true,
adminOnly: true,
responses: [
{ status: 200, description: 'Aggregation completed' },
{ status: 401, description: 'Invalid cron secret' },
],
},
{
id: 'cron-cart-abandonment',
method: 'POST',
path: '/api/cron/cart-abandonment',
summary: 'Process abandoned carts',
description: 'Sends abandoned cart reminder emails (called by cron)',
category: 'cron',
requiresAuth: true,
adminOnly: true,
responses: [
{ status: 200, description: 'Processed abandoned carts' },
{ status: 401, description: 'Invalid cron secret' },
],
},
{
id: 'cron-slo-snapshot',
method: 'POST',
path: '/api/cron/slo-snapshot',
summary: 'Create SLO snapshot',
description: 'Creates a snapshot of current SLO metrics (called by cron)',
category: 'cron',
requiresAuth: true,
adminOnly: true,
responses: [
{ status: 200, description: 'SLO snapshot created' },
{ status: 401, description: 'Invalid cron secret' },
],
},
// Documentation
{
id: 'docs-openapi',
method: 'GET',
path: '/api/docs',
summary: 'Get API documentation',
description: 'Returns OpenAPI/Swagger documentation for the API',
category: 'public',
requiresAuth: false,
responses: [
{ status: 200, description: 'OpenAPI specification' },
],
},
// Email
{
id: 'email-unsubscribe',
method: 'GET',
path: '/api/email/unsubscribe',
summary: 'Unsubscribe from emails',
description: 'Processes email unsubscribe requests via token',
category: 'public',
requiresAuth: false,
parameters: [
{ name: 'token', type: 'string', required: true, location: 'query', description: 'Unsubscribe token' },
],
responses: [
{ status: 200, description: 'Successfully unsubscribed' },
{ status: 400, description: 'Invalid or expired token' },
],
},
{
id: 'email-webhook',
method: 'POST',
path: '/api/email/webhook',
summary: 'Email provider webhook',
description: 'Receives webhooks from email provider (bounces, complaints, etc.)',
category: 'system',
requiresAuth: false,
responses: [
{ status: 200, description: 'Webhook processed' },
{ status: 400, description: 'Invalid webhook signature' },
],
},
// Health Checks
{
id: 'health-db',
method: 'GET',
path: '/api/health/db',
summary: 'Database health check',
description: 'Checks database connectivity and returns status',
category: 'system',
requiresAuth: false,
responses: [
{ status: 200, description: 'Database healthy', example: { status: 'healthy', latency: 5 } },
{ status: 503, description: 'Database unavailable' },
],
},
// Images
{
id: 'images-upload',
method: 'POST',
path: '/api/images/upload',
summary: 'Upload image',
description: 'Uploads an image to cloud storage',
category: 'system',
requiresAuth: true,
requestBody: {
contentType: 'multipart/form-data',
fields: [
{ name: 'file', type: 'string', required: true, description: 'Image file (multipart/form-data binary)' },
{ name: 'folder', type: 'string', required: false, description: 'Storage folder' },
],
},
responses: [
{ status: 200, description: 'Image uploaded' },
{ status: 400, description: 'Invalid file type or size' },
{ status: 401, description: 'Authentication required' },
],
},
];
|