hubvault.server.config
Server configuration helpers for hubvault.server.
This module normalizes all startup surfaces onto the same immutable configuration object so CLI startup, import startup, and ASGI startup behave consistently.
The module contains:
ServerConfig- Normalized embedded-server configuration
SERVER_MODE_API
- hubvault.server.config.SERVER_MODE_API = 'api'
str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
SERVER_MODE_FRONTEND
- hubvault.server.config.SERVER_MODE_FRONTEND = 'frontend'
str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
DEFAULT_SERVER_PORT
- hubvault.server.config.DEFAULT_SERVER_PORT = 9472
int([x]) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4
ServerConfig
- class hubvault.server.config.ServerConfig(repo_path: Path, mode: str = 'frontend', host: str = '127.0.0.1', port: int = 9472, token_ro: Tuple[str, ...] = (), token_rw: Tuple[str, ...] = (), open_browser: bool = False, init: bool = False, initial_branch: str = 'main', large_file_threshold: int | None = None)[source]
Normalized runtime configuration for the embedded server.
- Parameters:
repo_path (pathlib.Path) – Repository root served by the app
mode (str) – Server mode, either
"api"or"frontend"host (str) – Host interface to bind
port (int) – TCP port to bind
token_ro (Tuple[str, ...]) – Read-only bearer tokens
token_rw (Tuple[str, ...]) – Read-write bearer tokens
open_browser (bool) – Whether to open the local browser URL after startup
init (bool) – Whether to create the repository automatically when missing
initial_branch (str) – Initial branch name used with
initlarge_file_threshold (Optional[int]) – Optional chunking threshold used during repository creation
- __post_init__() None[source]
Validate and normalize the dataclass fields after construction.
- Returns:
None.- Return type:
None
- Raises:
ValueError – Raised when mode, port, token, or threshold values are invalid.
- property browser_url: str
Return the browser-friendly local URL for the bound server.
- Returns:
Browser URL using a loopback-safe host when bound to all interfaces
- Return type:
str
- classmethod from_env(**overrides) ServerConfig[source]
Build a config object from
HUBVAULT_*environment variables.- Parameters:
overrides (dict) – Explicit field overrides applied on top of the environment
- Returns:
Normalized server configuration
- Return type:
- Raises:
TypeError – Raised when unsupported override keys are provided.
ValueError – Raised when required values such as
repo_pathare missing.
- property ui_enabled: bool
Whether the frontend static UI should be served.
- Returns:
Truewhen the frontend assets should be mounted- Return type:
bool