@rsc-kit/mcp 0.30.48 → 0.30.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/recipes.js +25 -11
- package/dist/recipes.js.map +1 -1
- package/guides/go.md +84 -4
- package/guides/laravel.md +110 -10
- package/guides/public-forms.md +32 -22
- package/guides/your-own-backend.md +40 -6
- package/package.json +2 -2
package/dist/recipes.js
CHANGED
|
@@ -1789,6 +1789,13 @@ Guard a route in Laravel's vocabulary, no route declared in PHP:
|
|
|
1789
1789
|
// resources/js/app/admin/middleware.ts
|
|
1790
1790
|
export const middleware = ['auth', 'verified', 'can:update,post']
|
|
1791
1791
|
|
|
1792
|
+
They run against the page's request, not the host call's: signed checks the
|
|
1793
|
+
link the visitor followed, throttle counts per visitor and once per page load,
|
|
1794
|
+
and can:update,post gets the {post} the route bound - bind it with
|
|
1795
|
+
Route::bind or Route::model, since a page has no controller signature for
|
|
1796
|
+
implicit binding. In Go, a guard reads rsckit.PageFrom(ctx) (URL, and Params:
|
|
1797
|
+
only the route's own, never the query) and rsckit.ClientIP(ctx).
|
|
1798
|
+
|
|
1792
1799
|
Make one: php artisan make:rsc-action Orders --method=cancel --auth
|
|
1793
1800
|
--can=update,Order --middleware=throttle:60,1 --revalidate=orders (--rpc for
|
|
1794
1801
|
an rpc() class under app/Rsc; no --method = invokable; a slash nests,
|
|
@@ -2913,22 +2920,29 @@ passed. A refusal handle() decides goes under its field:
|
|
|
2913
2920
|
import { fieldErrors } from '@rsc-kit/core/action'
|
|
2914
2921
|
if (await subscribed(email)) fieldErrors({ email: 'Already on the list.' })
|
|
2915
2922
|
|
|
2916
|
-
A BACKEND, WITH NO SCHEMA: defineForm({ name, action:
|
|
2917
|
-
|
|
2918
|
-
|
|
2923
|
+
A BACKEND, WITH NO SCHEMA: defineForm({ name, action: contactSend, theme }),
|
|
2924
|
+
with contactSend imported from the generated server-actions module - the
|
|
2925
|
+
action itself, never its name as a string (a string throws). No form, no
|
|
2926
|
+
handle, no zod. bunx rsc-kit make:form contactSend writes forms/contact.ts.
|
|
2927
|
+
The action is a Laravel class in app/Rsc/Actions (Contact::send is
|
|
2928
|
+
contactSend; a class in app/Rsc is rpc only and has no action) or Go's
|
|
2929
|
+
reg.HandleAction("contactSend", "Contact.send", fn). Fields and browser checks
|
|
2930
|
+
come from what it takes (rsc-host.json): a Laravel FormRequest's rules(), or a
|
|
2919
2931
|
Go struct, whose validate tags are read as hints and never run, so the Go
|
|
2920
|
-
function must still check.
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
handle: (values) =>
|
|
2932
|
+
function must still check. It takes one object; a file needs form and handle.
|
|
2933
|
+
A 422 from Laravel (a FormRequest type-hinted on the method, whose authorize()
|
|
2934
|
+
returns true) or Go (rsckit.InvalidField) lands under the same fields,
|
|
2935
|
+
uncaught. To check in TypeScript first, keep a schema and
|
|
2936
|
+
handle: (values) => contactSend(values).
|
|
2925
2937
|
|
|
2926
2938
|
THE BOT TRAP: every form carries a hidden field named homepage. Filled in, the
|
|
2927
2939
|
submission is answered as a success and dropped - handle() never runs. So a
|
|
2928
2940
|
form cannot have a field named homepage. It is not a CAPTCHA; rate-limit a form
|
|
2929
|
-
worth attacking
|
|
2930
|
-
|
|
2931
|
-
|
|
2941
|
+
worth attacking. Every host call carries the visitor's address
|
|
2942
|
+
(X-Rsc-Client-Ip), so Laravel's throttle:5,1 on the action counts each
|
|
2943
|
+
visitor ($request->ip()), as Go's rsckit.ClientIP(ctx) does. Behind a load
|
|
2944
|
+
balancer or Cloudflare set RSC_TRUST_FORWARDED=1 on the renderer, or every
|
|
2945
|
+
visitor arrives as the balancer.
|
|
2932
2946
|
|
|
2933
2947
|
A THEME draws it with one component, PublicForm (type FormsTheme from
|
|
2934
2948
|
@rsc-kit/press/forms); replace it with theme: { ...shadcn, PublicForm: Mine }.
|