All files / src/lib/api-docs/endpoints/admin cron.ts

100% Statements 45/45
100% Branches 0/0
100% Functions 0/0
100% Lines 45/45

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 461x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
/**
 * Admin Cron Job Endpoints
 * Scheduled tasks and maintenance operations
 */
 
import type { ApiEndpoint } from '@/types/api-docs';
 
export const adminCronEndpoints: ApiEndpoint[] = [
  {
    id: 'admin-cron-cleanup-errors',
    method: 'GET',
    path: '/api/cron/cleanup-errors',
    summary: 'Clean up old error data',
    description:
      'Removes error logs older than 30 days, resets counts on resolved errors, and deletes orphaned statistics. Should be called by a cron scheduler (e.g., Vercel Cron).',
    category: 'admin-cron',
    requiresAuth: true,
    adminOnly: true,
    parameters: [],
    requestBody: undefined,
    responses: [
      {
        status: 200,
        description: 'Cleanup completed successfully',
        example: {
          success: true,
          retentionDays: 30,
          cutoffDate: '2024-01-01T00:00:00.000Z',
          deletedLogs: 150,
          resetStatistics: 25,
          deletedOrphanedStats: 10,
          durationMs: 1250,
        },
      },
      {
        status: 401,
        description: 'Unauthorized - invalid or missing CRON_SECRET',
      },
      {
        status: 500,
        description: 'Cleanup failed',
      },
    ],
  },
];