Server.decode
luastra/serverServer.decode(value: string): DecodeResult
Parses the bounded payload returned by a Luastra server operation into a discriminated DecodeResult. It separates envelope validity from the transport success reported to app.resolve.
Before you use it
Add luastra/server to this module's dependencies in luastra.json, then import it with require("luastra/server"). Declare rpc.call in luastra.json and configure a declared backend operation with a deployed trusted handler. Application code should prefer its generated operation function and decoder.
How it fits
Server.decode synchronously checks the matching bounded success envelope; schema-v2 domain decoding remains operation-specific and generated.
When to use it
Use Server.decode on a successful server resolve payload before reading operation data. Treat decode failure as an untrusted or incompatible response and keep application state unchanged or move to an explicit error state.
Parameters
| Parameter | Type / values | Description |
|---|---|---|
| value | string | Successful transport payload whose server envelope must still be validated. |
Returns
DecodeResult — a discriminated decode result; branch on success before reading decoded fields or failure data.
What happens next
A tagged result containing result.fields or a bounded decode error.
Failures and fixes
Handle transport failure, envelope decode failure, and domain validation failure separately. The static web build does not deploy trusted backend handlers, credentials, or production operations for you.
Availability
Public-source alpha API in 0.5.0-alpha; production backend deployment remains application-owned.
Focused example
local Server = require("luastra/server")
local result = Server.decode(payload)
if result.success then records = result.fields else errorMessage = result.error endContinue with a complete recipe
This checked recipe provides the declaration, generated client, trusted handler, manifest, test, and run context behind Server.decode.
Open call a server function recipe