feat(access-api): validate wallet, community, and resource inputs with zod#30
Open
Dwifax wants to merge 1 commit into
Open
feat(access-api): validate wallet, community, and resource inputs with zod#30Dwifax wants to merge 1 commit into
Dwifax wants to merge 1 commit into
Conversation
- Add zod schemas for Stellar wallet, communityId, role query, and access-check body - Wire parseParams/parseQuery/parseBody helpers into all four routes so malformed inputs return a structured 400 with field-level errors before reaching the service - Add jest config and unit tests for schemas and parse helpers (21 tests) - Drop zod into runtime dependencies (was only a type-only devDep)
Contributor
|
Do resolve conflicts |
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.
Summary
Closes #1
Adds structured request validation across the four
access-apiroutes so malformed inputs return a clear 400 with field-level errors before reaching the service layer.Changes
src/validators.ts— new module with zod schemas for Stellar wallet address,communityIdparam,rolequery, and theaccess-checkrequest body, plus three parse helpers (parseParams,parseQuery,parseBody) that wrap Fastify's request and return a structured 400 on failuresrc/routes.ts— wire parse helpers into all four routes; each handler now resolves the parsed value before calling the service so a bad input short-circuits the requestpackage.json— movezodfrom devDependencies to dependencies (it's now a runtime dep, not a type-only one)jest.config.js+test/validators.test.ts+test/parse.test.ts— 21 jest cases covering schema acceptance/rejection, edge cases (0x prefix variations, role enum, multi-field body), and the parse helper response shapeTest coverage (21 cases)
G, reject too-short, reject non-base32Verification
Notes
pnpm --filter @guildpass/shared-types buildonce for type resolution (already done in fork)Checklist