feat(protect): Next.js, SvelteKit, Astro, Fastify, Express adapters#83
Merged
Conversation
|
Adapters added cleanly with comprehensive testing and clear structure. 🎯 Quality: 100% Elite · 📦 Size: Large — consider splitting if possible 📈 This month: Your 35th PR — above team average · Averaging Excellent |
Contributor
Author
|
/review |
mariojgt
approved these changes
Jul 15, 2026
ejntaylor
approved these changes
Jul 15, 2026
26a9afa to
3487103
Compare
f863454 to
0c63355
Compare
Two new per-stack adapters on the #81 interface, dependency-free (anchor + #region markers, same approach as tanstack — no AST parser, keeping dependencies:{}). - Express: detect (express dep + an `= express()` site), scaffold the generic guard, and wire `app.use(patchstackMiddleware)` right after the app is created (import + region-marked insert, idempotent). verify() checks the guard is scaffolded + the middleware is wired. - Next.js: detect (next dep); scaffold `middleware.ts` (+ co-located patchstack.rules.json) from a new template running the request-phase guard as edge middleware. An EXISTING middleware is never overwritten — we scaffold the rules and print a plan instead. verify() checks the managed middleware + rules are present. - Registered in the orchestrator (tanstack → next → express → generic fallback); AGENT-INSTALL lists the newly auto-wired stacks. +4 tests. 451 tests pass, typecheck + build clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Three more per-stack adapters (Arcjet-parity for the JS frameworks, minus NestJS/Python),
dependency-free — same anchor + #region approach, no AST parser, dependencies:{} unchanged.
- SvelteKit + Astro: seam-file-is-the-guard. New shared `seam.ts` (wireSeam/verifySeam) scaffolds
the framework's server hook from a template (`src/hooks.server.ts` → handle, `src/middleware.ts`
→ onRequest) + co-located patchstack.rules.json. An EXISTING hook is never overwritten — scaffold
rules + print a compose-with-sequence() plan instead.
- Fastify: register-into-app (like express). scaffoldGeneric now takes a guard-template arg so the
Fastify plugin (builds a Request from the parsed fastify request → fetchGuard) lands as the guard;
wire `app.register(patchstackFastify)` after the fastify() instance.
- Registered most-specific-first (tanstack → next → sveltekit → astro → fastify → express → generic).
- AGENT-INSTALL lists the newly auto-wired stacks.
+5 tests. 456 pass, typecheck + build clean.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
0c63355 to
1616ab8
Compare
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.
Stacked on #82. Five new per-stack adapters on the #81 interface — dependency-free (anchor +
#regionmarkers, same as the tanstack adapter; no AST parser,dependencies:{}unchanged per the zero-dep posture). Brings JS-framework coverage to Arcjet parity minus NestJS (decorator/module wiring — deferred) and Python (out of scope; JS engine).Two wiring shapes:
Seam-file-is-the-guard (new shared
install/seam.ts) — scaffold the framework's server hook from a template + co-locatepatchstack.rules.json; an existing hook is never overwritten (scaffold rules + print asequence()compose plan):middleware.ts(edge request-phase guard)src/hooks.server.ts→handlesrc/middleware.ts→onRequestRegister-into-app — scaffold guard to
src/patchstack/guard.ts+ patch the app file after the instance is created (idempotent):app.use(patchstackMiddleware)app.register(patchstackFastify)(guard plugin rebuilds aRequestfrom the parsed fastify request →fetchGuard)scaffoldGenericgained a guard-template arg (for the Fastify plugin). Registered most-specific-first: tanstack → next → sveltekit → astro → fastify → express → generic fallback.AGENT-INSTALLlists all auto-wired stacks.+9 tests. 456 pass, typecheck + build clean.
🤖 Generated with Claude Code