feat: add centralized snippet request validation - #177
Merged
SudiptaPaul-31 merged 4 commits intoSep 1, 2026
Merged
Conversation
Introduce a single validation module reused by every snippet operation (create, update, import, share): title 3-100 chars, supported-language enum, code size/whitespace limits, Stellar wallet format+checksum via the SDK, and visibility restricted to private/public/shared. All failures return one consistent JSON error payload with HTTP 400 and nothing is persisted for invalid input. Adds a bounded ZIP reader plus an import endpoint that validates JSON/ZIP manifests before persistence and always assigns the authenticated wallet as owner. Includes a visibility column migration and comprehensive unit/route tests. Closes SudiptaPaul-31#157 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
Owner
|
@Okorie2000-code resolve conflicts |
… regenerate lockfile - createSnippetSchema now uses walletAddressSchema (Stellar StrKey checksum validation) and languageSchema (enum allowlist) so invalid wallet addresses and unsupported languages are rejected with a ZodError before any DB call - Added optional visibility field to createSnippetSchema using visibilitySchema - Regenerated package-lock.json to match current package.json and resolve lockfile conflict with main
- lib/snippet.service.test.ts: merged upstream's IPFSService import and our ZodError import; updated duplicate/fork tests to match new repository- delegated service API; kept all Zod validation tests (wallet, language, visibility) - package.json: merged devDependencies, removed duplicate keys introduced by the conflict, added undici and eslint/typescript-eslint from upstream - package-lock.json: regenerated cleanly from merged package.json All 19 tests in lib/snippet.service.test.ts pass.
Contributor
Author
done sir. Am really sorry for the delay.....due to some issues... thanks sir. |
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.
Introduce a single validation module reused by every snippet operation (create, update, import, share): title 3-100 chars, supported-language enum, code size/whitespace limits, Stellar wallet format+checksum via the SDK, and visibility restricted to private/public/shared. All failures return one consistent JSON error payload with HTTP 400 and nothing is persisted for invalid input. Adds a bounded ZIP reader plus an import endpoint that validates JSON/ZIP manifests before persistence and always assigns the authenticated wallet as owner. Includes a visibility column migration and comprehensive unit/route tests.
Closes #157