Skip to content

feat(protect): Next.js, SvelteKit, Astro, Fastify, Express adapters#83

Merged
patchstackdave merged 2 commits into
mainfrom
feat/protect-adapters-ast
Jul 15, 2026
Merged

feat(protect): Next.js, SvelteKit, Astro, Fastify, Express adapters#83
patchstackdave merged 2 commits into
mainfrom
feat/protect-adapters-ast

Conversation

@patchstackdave

@patchstackdave patchstackdave commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Stacked on #82. Five new per-stack adapters on the #81 interface — dependency-free (anchor + #region markers, 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-locate patchstack.rules.json; an existing hook is never overwritten (scaffold rules + print a sequence() compose plan):

  • Next.jsmiddleware.ts (edge request-phase guard)
  • SvelteKitsrc/hooks.server.tshandle
  • Astrosrc/middleware.tsonRequest

Register-into-app — scaffold guard to src/patchstack/guard.ts + patch the app file after the instance is created (idempotent):

  • Expressapp.use(patchstackMiddleware)
  • Fastifyapp.register(patchstackFastify) (guard plugin rebuilds a Request from the parsed fastify request → fetchGuard)

scaffoldGeneric gained a guard-template arg (for the Fastify plugin). Registered most-specific-first: tanstack → next → sveltekit → astro → fastify → express → generic fallback. AGENT-INSTALL lists all auto-wired stacks.

+9 tests. 456 pass, typecheck + build clean.

AGENT-INSTALL.md changed → field-test before publishing.

🤖 Generated with Claude Code

@coderbuds

coderbuds Bot commented Jul 15, 2026

Copy link
Copy Markdown

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

See how your team is trending →

@patchstackdave patchstackdave changed the title feat(protect): Express + Next.js adapters feat(protect): Next.js, SvelteKit, Astro, Fastify, Express adapters Jul 15, 2026
@patchstackdave

Copy link
Copy Markdown
Contributor Author

/review

@patchstackdave patchstackdave force-pushed the feat/protect-verify-and-plan branch from 26a9afa to 3487103 Compare July 15, 2026 15:43
@patchstackdave patchstackdave force-pushed the feat/protect-adapters-ast branch from f863454 to 0c63355 Compare July 15, 2026 15:44
Base automatically changed from feat/protect-verify-and-plan to main July 15, 2026 15:46
patchstackdave and others added 2 commits July 15, 2026 17:46
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>
@patchstackdave patchstackdave force-pushed the feat/protect-adapters-ast branch from 0c63355 to 1616ab8 Compare July 15, 2026 15:46
@patchstackdave patchstackdave merged commit 1028b09 into main Jul 15, 2026
4 checks passed
@patchstackdave patchstackdave deleted the feat/protect-adapters-ast branch July 15, 2026 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants