Description
Create backend functionality for duplicating an existing snippet into another user's collection. The new snippet should preserve useful metadata while maintaining a reference to the original snippet so the relationship between the original and forked versions can be tracked.
Requirements
- Duplicate functionality — create an identical copy of a snippet in the requesting user’s collection.
- Fork functionality — create a new snippet derived from an existing one, with editable content.
- Preserve metadata — retain title, tags, language, and creation timestamp.
- Reference to original — store
originalSnippetId in forked/duplicated snippets for traceability.
- Ownership transfer — new snippet belongs to the requesting user, not the original author.
- API endpoints — expose REST/GraphQL endpoints for duplication and forking actions.
- Audit logging — record duplication/fork events for transparency.
Acceptance Criteria
- ✅ New snippet created with unique ID — duplication/fork never overwrites the original.
- ✅ Metadata preserved — tags, language, and other attributes copied correctly.
- ✅ Original reference maintained — forked/duplicated snippets include
originalSnippetId.
- ✅ Ownership updated — new snippet belongs to the requesting user.
- ✅ Endpoints secured — only authenticated users can fork/duplicate snippets.
- ✅ Tests included — cover valid duplication/forking, invalid requests, and edge cases.
Description
Create backend functionality for duplicating an existing snippet into another user's collection. The new snippet should preserve useful metadata while maintaining a reference to the original snippet so the relationship between the original and forked versions can be tracked.
Requirements
originalSnippetIdin forked/duplicated snippets for traceability.Acceptance Criteria
originalSnippetId.