Std.Live
Std.Live — server-driven web UI backend (Layer 3 Sky source).
Types
type AppConfig model msg
type Route
type Running
Values
address : Running -> String
The address a [`serve`]d app is bound to, as `host:port`
api : String -> (Request -> Task Error Response) -> Route
`api path handler` — register a raw JSON/HTTP endpoint alongside the
app : AppConfig model msg -> Task Error ()
Open the HTTP listener and run the TEA loop. Sits at the top of `main`.
bindSessionUser : String -> Task Error ()
`bindSessionUser userId` — bind the CURRENT live session to an application
config : { init : a -> ( model, Cmd msg ) , update : msg -> model -> ( model, Cmd msg ) , view : model -> Html msg , subscriptions : model -> Sub msg , routes : List Route , notFound : page } -> AppConfig model msg
Build the app config from the six required fields. Attach optional
endSession : () -> Task Error ()
`endSession ()` — end the CURRENT live session: sign-out, or "start over".
lifecycle : msg -> msg
Tag a message as a lifecycle message (identity at the type level; the
route : String -> page -> Route
`route path page` — register a page route. Put literals before
serve : AppConfig model msg -> Task Error Running
Start the app and return once its listener is bound, with a handle to
sessionKey : () -> Task Error String
`sessionKey ()` — a key for the CURRENT live session that stays the same
stop : Running -> Task Error ()
Stop a [`serve`]d app: the listener stops accepting, every open SSE
withAnalytics : { pageViews : Bool } -> AppConfig model msg -> AppConfig model msg
Opt into Sky.Live auto page-view analytics —
withAnalyticsIdentify : (model -> Maybe String) -> AppConfig model msg -> AppConfig model msg
Attribute auto page-views to an already-authenticated session: a resolver
withAuthSliding : { cookie : String , secretEnv : String , sameSite : String , revokedCheck : Maybe (String -> Task Error Bool) } -> AppConfig model msg -> AppConfig model msg
Opt into SLIDING (rolling) auth tokens — the middleware re-issues a
withConsoleAuth : (Request -> Task Error (Maybe a)) -> AppConfig model msg -> AppConfig model msg
Gate the `/_sky/console` mount — `consoleAuth req` returns the
withConsoleAuthModel : (Request -> model -> Task Error (Maybe a)) -> AppConfig model msg -> AppConfig model msg
Like `withConsoleAuth`, but `check req model` also receives the console
withDurable : durable -> AppConfig model msg -> AppConfig model msg
Attach durable wiring (from `Std.App.withDurable`); the live loop restores
withEmbedded : AppConfig model msg -> AppConfig model msg
Run the app as ONE task inside a larger Task program (embedded mode).
withGuard : (msg -> model -> Result Error ()) -> AppConfig model msg -> AppConfig model msg
Per-Msg guard — `guard msg model` returns `Err` to reject the message
withHead : (model -> List (Html msg)) -> AppConfig model msg -> AppConfig model msg
Per-page `<head>` injection — `head model` returns the extra `<head>`
withIdleEvict : String -> AppConfig model msg -> AppConfig model msg
Tiered-session-cache idle-evict window ("5m" / "0"/"off" to disable).
withInput : String -> AppConfig model msg -> AppConfig model msg
When the JS driver reports an input's value: `"debounce"` (after a typing
withMaxBodyBytes : Int -> AppConfig model msg -> AppConfig model msg
Maximum bytes accepted on a single TEA event request (the channel that
withOnNavigate : (page -> msg) -> AppConfig model msg -> AppConfig model msg
Hook fired on in-app navigation (initial mount, `sky-nav` fetch,
withPort : Int -> AppConfig model msg -> AppConfig model msg
Set the listen port.
withRevocation : Db -> AppConfig model msg -> AppConfig model msg
Opt into PULL-model user revocation + suspension. Hand the runtime the
withSessionTransport : String -> AppConfig model msg -> AppConfig model msg
How the session id travels: `"cookie"` (the default) or `"header"`.
withStatic : String -> AppConfig model msg -> AppConfig model msg
Serve a static directory at `/static` (override the mount with
withStaticUrl : String -> AppConfig model msg -> AppConfig model msg
Override the static mount path (default `/static`).
withStatus : { reconnecting : String , offline : String } -> AppConfig model msg -> AppConfig model msg
Override the connection-status banner strings —
withStore : String -> AppConfig model msg -> AppConfig model msg
Select the session store kind ("memory" / "sqlite" / "redis" /
withStorePath : String -> AppConfig model msg -> AppConfig model msg
Session store path / URL.
withTtl : String -> AppConfig model msg -> AppConfig model msg
Session TTL ("30m" / "24h" / bare seconds).