brazier/config

Values

pub const env_prefix: String

The prefix of every Brazier environment variable.

pub const framework_env_vars: List(String)

The environment variables Brazier itself reads. refuse_renamed_env checks their pre-rename names when an application or cluster starts.

pub fn get_env(name: String) -> option.Option(String)

Get an environment variable, returning None if not set.

pub fn get_env_int(
  name: String,
  default: Int,
) -> Result(Int, error.BrazierError)

Get an integer environment variable. Unset gives default; set to something that is not an integer is an error (a typo in PORT must not quietly start the server elsewhere).

pub fn get_env_or(name: String, default: String) -> String

Get an environment variable with a default for when it is unset.

pub fn is_production() -> Bool

Check if running in production mode.

pub const min_secret_key_bytes: Int

The minimum secret_key length in bytes. Join tokens and the cluster peer check are signed with HMAC-SHA256, whose security needs a key of at least the hash length (32 bytes; RFC 2104 section 3). Generate one with openssl rand -base64 48.

pub fn port() -> Result(Int, error.BrazierError)

Get the port from PORT env var, defaulting to 8080 when unset. A set value must be an integer in 0..65535.

pub fn secret_key() -> Result(String, error.BrazierError)

Get the secret key from the SECRET_KEY env var. It must be set and pass validate_secret_key; there is no built-in default.

pub fn validate_secret_key(
  key: String,
) -> Result(String, error.BrazierError)

Check that a secret key is strong enough to sign tokens: at least min_secret_key_bytes bytes and not the formerly built-in dev secret. The key itself is never logged or included in the error.

✨ Search Document