You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit cb856ec
Browse filesBrowse the repository at this point in the historyBrowse files
Give the agent one recipe for wiring any Node.js app (#448)
Setup wires the frameworks it recognises and leaves a generic guard for
everything else. The guide described the procedure in general terms, and
agents filled the gap by writing their own createProtection guard, which
has no read-only rules credential and cannot fetch rule updates.
AGENT-INSTALL.md now has a short recipe under "Completing guard wiring":
use the guard file setup wrote (never write your own or copy the
.patchstack cache), wrap the app's one request entry with the export
that fits its shape (Fetch handler, Node (req, res), Express/Connect,
Fastify), run setup again so the guard's rules file gets the site's rules
and the credential, then check with protect --check and --runtime.
Also corrects the refresh interval it states: 5 minutes, plus a
background re-check every 30 seconds while serving, not 45 minutes.
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: AGENT-INSTALL.md
+31-1Lines changed: 31 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -496,7 +496,7 @@ It is server-only. Never put it in the widget tag, client bundles, or public env
496
496
services and separately deployed functions are not protected by guarding the frontend server;
497
497
keep backend authorization/RLS and install a guard at each independently exposed backend.
498
498
499
-
Generated guards refresh live rules every 45 minutes (15 seconds in an explicit sandbox). `PATCHSTACK_RULES_REFRESH_SECONDS`, set to a positive number in the app's environment, overrides that interval (minimum 5 seconds).
499
+
Generated guards refresh live rules every 5 minutes (15 seconds in an explicit sandbox), and while serving traffic also re-check them in the background every 30 seconds. `PATCHSTACK_RULES_REFRESH_SECONDS`, set to a positive number in the app's environment, overrides that interval (minimum 5 seconds).
|`(req, res)` on Node's `http` server, including what Koa's `app.callback()` returns |`patchstackMiddleware`, before anything reads the body |`http.createServer((req, res) => patchstackMiddleware(req, res, () => handler(req, res)))`|
611
+
| Express or Connect |`patchstackMiddleware`, registered first, before body parsers and routes |`app.use(patchstackMiddleware)`|
612
+
| Fastify | the plugin `protect` writes for it | run `npx @patchstack/connect protect`|
613
+
614
+
Keep any extra arguments the host passes (`env`, `ctx`) flowing through to the handler. The wrapped
615
+
handler is called once for an allowed request; a blocked one gets the guard's response instead.
616
+
3.**Run `npx @patchstack/connect setup` again.** It writes the site's current rules and the read-only
617
+
credential into the guard's rules file. Then `npx @patchstack/connect protect --check` must exit 0.
618
+
4.**Check that a request reaches it:**`protect --check --runtime` when the entry runs under plain
619
+
`node`, otherwise the local request test in step 4 above.
620
+
621
+
If the entry matches none of these shapes, do not invent an adapter or write a guard of your own: leave
622
+
it unwired and hand off as described in "When wiring cannot be completed".
623
+
594
624
### Framework entry points to inspect
595
625
596
626
These are navigation hints for agent-assisted integration, not additional automatic adapters or a
0 commit comments