← Server functions

Server.decode

luastra/server
Server.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

ParameterType / valuesDescription
valuestringSuccessful 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 end

Continue learning

Prerequisites

Server.DecodeResult

Companions

Server.DecodeFailure

Next steps

Server.DecodeSuccess

Complete inventory

View all pages in Server functions
← Previous: Server.callV2Next: Server.decodeV2 →