Open
Description
Description
Add expiry functionality with Cloudflare Worker for cleanup.
Priority
HIGH - Key differentiating feature for temporary code sharing.
Tasks
- Add expiry options to create form
- Display expiry status on view page
- Create countdown timer component
- Implement Cloudflare Worker for cleanup
- Configure CRON trigger in wrangler.toml
- Add batch deletion logic
- Create expiry warning notifications
- Handle timezone considerations
Technical Requirements
- Support expiry times: 1 hour, 24 hours, 7 days, 30 days
- Store expiry as ISO timestamp in metadata
- Implement efficient batch cleanup
- Handle edge cases (expired during viewing)
- Show remaining time in user's timezone
- Cleanup worker must handle R2 pagination
- Consider rate limits for batch operations
Acceptance Criteria
- Users can set expiry times
- Countdown displays accurately
- Expired gists are deleted automatically
- Warnings appear before expiry
- Batch cleanup is efficient
- Timezone handling is correct
- Cleanup worker runs reliably
- R2 storage is cleaned up completely
Dependencies
- Existing components:
- ExpirySelector
- Badge (for status display)
- Tooltip (for countdown)
- Cloudflare Workers CRON triggers
- R2 batch operations
Worker Implementation
// Scheduled worker for cleanup
export default {
async scheduled(event, env, ctx) {
// List gists with expiry < now
// Batch delete expired gists
// Clean up R2 blobs
// Log cleanup stats
}
}
CRON Configuration
# wrangler.toml
[triggers]
crons = ["0 */15 * * *"] # Every 15 minutes
Implementation Notes
- Use R2 list operations with prefix for efficiency
- Implement exponential backoff for retries
- Add monitoring/alerting for cleanup failures
- Consider soft delete with grace period
- Add admin endpoint to trigger manual cleanup
Estimated Time
4-5 days
References
- Phase 6 Tracking:
docs/PHASE_6_ISSUE_TRACKING.md
(Issue feat: implement Create Gist API with improved error handling #115) - Cloudflare Workers docs for CRON
- R2 batch operations documentation