Repository navigation
feat(docs-api): add snippet documentation management API and sanitization (#217) - #233
Open
jeffrey-graham wants to merge 1 commit into
Open
jeffrey-graham wants to merge 1 commit into
jeffrey-graham wants to merge 1 commit into
Conversation
|
@jeffrey-graham is attempting to deploy a commit to the Sudipta 's projects Team on Vercel. A member of the Team first needs to authorize it. |
jeffrey-graham
force-pushed
the
feat/snippet-documentation-api-217
branch
from
November 11, 2026 08:28
fae5e4f to
8f9e68b
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #217
Adds structured snippet documentation management (
overview,usageInstructions,prerequisites,setupSteps,inputExample,outputExample, andnotes) inlib/snippet-documentation-service.ts, exposes CRUD handlers atapp/api/snippets/[id]/documentation/route.ts, and wires stored documentation intoGET /api/snippets/[id].Implementation details
lib/snippet-documentation-service.ts): Rejects empty payloads, unknown fields, oversized text/list/example sections, and malformed JSON examples. Strips<script>,<iframe>,<object>,<embed>,<style>, inlineon*event attributes,javascript:/vbscript:/data:text/htmlURIs, and disallowed control bytes before storage.app/api/snippets/[id]/documentation/route.ts): Extracts caller wallets viaOwnershipMiddleware.extractWalletAddress(supporting bothx-wallet-addressandBearerJWTs) and connectsSnippetDocumentationServicetoSnippetRepository+permissions.service(canEdit/canView/isSharedWith) so missing DB snippets return404, unauthorized writes return401/403, andprivate/sharedvisibility rules apply onGET.app/api/snippets/[id]/route.ts): Attaches stored documentation on authorizedGET /api/snippets/[id]responses (and supports explicit?includeDocumentation=trueempty-state opt-in without altering existing responses for undocumented snippets).Local verification
./node_modules/.bin/eslint "lib/snippet-documentation-service.ts" "app/api/snippets/[id]/documentation/route.ts" "app/api/snippets/[id]/route.ts" "lib/__tests__/snippet-documentation-service.test.ts"-> 0 errors, 0 warnings./node_modules/.bin/tsc --noEmit-> 0 errors in touched files./node_modules/.bin/jest --runInBand --runTestsByPath "lib/__tests__/snippet-documentation-service.test.ts" "app/api/snippets/[id]/route.test.ts"-> 2 suites passed (19/19 tests passed)