/actions/coupon_detail?id=42&tab=codes gives ctx.params the value { id: '42', tab: 'codes' }; opening the action without a query string gives {}.
Usage
Describe the params the action expects with a zod schema inparams. The server checks the link against it before the handler runs, and ctx.params gets the parsed, typed value:
/actions/coupon_detail?id=42, put it in an email, a Slack message or your own admin, and the action opens straight on that coupon. Someone who is not logged in sees the login page first and lands on the same link afterwards.
A link that does not fit the schema does not start the action: the page shows The link does not fit this action with what is wrong, e.g. page: Expected number, received nan.
Values
Params are untrusted input
Anyone can write a link with any params, and opening it starts the action for whoever clicks it. Treatctx.params like a value typed into a form:
- describe it precisely in
params, e.g.z.string().uuid()rather thanz.string(); - check that the user may see or change the record it points to;
- ask with an
iocall before anything destructive, instead of deleting straight from a link.