Skip to content

feat: implement PUT and DELETE endpoints for gists #107

Closed
@nullcoder

Description

@nullcoder

Overview

Implement update and delete endpoints for gists with PIN validation to ensure only authorized users can modify or remove gists.

Tasks

  • Create PUT /api/gists/[id] endpoint
  • Create DELETE /api/gists/[id] endpoint
  • Implement PIN validation for both endpoints
  • Ensure atomic operations (metadata + blob)
  • Handle version conflicts
  • Add audit logging

Technical Requirements

  • Edge runtime compatible
  • PIN validation using PBKDF2 (matching creation hash)
  • Atomic updates/deletes for both metadata and blob
  • Optimistic locking for concurrent updates
  • Clean up both R2 objects on delete
  • Log security-relevant events

Endpoints

PUT /api/gists/[id]

  • Updates existing gist with new data
  • Requires PIN in request header or body
  • Validates PIN against stored hash
  • Updates both metadata and blob atomically
  • Response: 200 on success, 401 for wrong PIN, 404 if not found

DELETE /api/gists/[id]

  • Deletes gist permanently
  • Requires PIN in request header or body
  • Validates PIN against stored hash
  • Removes both metadata and blob
  • Response: 204 on success, 401 for wrong PIN, 404 if not found

Acceptance Criteria

  • Can update gist with correct PIN
  • Can delete gist with correct PIN
  • Returns 401 for incorrect PIN
  • Returns 404 for non-existent gists
  • Operations are atomic (all or nothing)
  • No orphaned data in R2
  • Version conflicts are handled gracefully

Dependencies

References

  • See docs/PHASE_5_ISSUE_TRACKING.md for detailed specifications

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiAPI endpoints and backend logicenhancementNew feature or requestpriority: highShould be done soon

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions