Files
gpt-engineer-app[bot] 16a1fa756d Continue Phase 2 Batch 2 and Batch 3
Migrate 6 background jobs to use wrapEdgeFunction: cleanup-old-versions, process-scheduled-deletions, data-retention-cleanup, run-cleanup-jobs, scheduled-maintenance, process-expired-bans. Replace old server routines with edgeFunction wrapper, add centralized logging, tracing, and standardized error handling, and adjust for batch-wise deployment.
2025-11-11 03:36:40 +00:00

39 lines
1.1 KiB
TypeScript

import { createClient } from 'https://esm.sh/@supabase/supabase-js@2.57.4';
import { createEdgeFunction } from '../_shared/edgeFunctionWrapper.ts';
import { edgeLogger } from '../_shared/logger.ts';
export default createEdgeFunction(
{
name: 'data-retention-cleanup',
requireAuth: false,
},
async (req, context, supabase) => {
edgeLogger.info('Starting data retention cleanup', { requestId: context.requestId });
// Call the master cleanup function
const { data, error } = await supabase.rpc('run_data_retention_cleanup');
if (error) {
edgeLogger.error('Error running data retention cleanup', {
error,
requestId: context.requestId
});
throw error;
}
edgeLogger.info('Data retention cleanup completed', {
results: data,
requestId: context.requestId
});
return new Response(
JSON.stringify({
success: true,
cleanup_results: data.cleanup_results,
timestamp: data.timestamp,
}),
{ headers: { 'Content-Type': 'application/json' } }
);
}
);