pocketenv/network

Manage network access for a sandbox.

Expose or unexpose ports to the internet and configure Tailscale for private network connectivity.

Values

pub fn expose(
  sb: sandbox.ConnectedSandbox,
  port: Int,
  description: option.Option(String),
) -> Result(option.Option(String), pocketenv.PocketenvError)

Exposes port on the sandbox to the internet. Returns a preview URL if one is generated by the platform.

Example

let assert Ok(url) = sb |> network.expose(3000, Some("Dev server"))
pub fn get_tailscale_auth_key(
  sb: sandbox.ConnectedSandbox,
) -> Result(option.Option(String), pocketenv.PocketenvError)

Retrieves the stored Tailscale auth key for the sandbox, if any.

Example

let assert Ok(key) = sb |> network.get_tailscale_auth_key()
pub fn setup_tailscale(
  sb: sandbox.ConnectedSandbox,
  auth_key: String,
) -> Result(Nil, pocketenv.PocketenvError)

Stores a Tailscale auth key for the sandbox, enabling private network access.

Example

let assert Ok(Nil) = sb |> network.setup_tailscale("tskey-auth-xxxx")
pub fn unexpose(
  sb: sandbox.ConnectedSandbox,
  port: Int,
) -> Result(Nil, pocketenv.PocketenvError)

Removes the public exposure of port on the sandbox.

Example

let assert Ok(Nil) = sb |> network.unexpose(3000)
Search Document