hubvault.server.deps

Shared dependency helpers for hubvault.server.

This module centralizes lightweight dependency-construction helpers that are shared by route factories and app bootstrap code.

get_repo_api_factory

hubvault.server.deps.get_repo_api_factory(config: ServerConfig) Callable[[], HubVaultApi][source]

Build a request-safe repository API factory for one server app.

Each invocation returns a fresh hubvault.api.HubVaultApi instance bound to the repository’s current default branch. This avoids sharing mutable backend transaction state across concurrent HTTP requests.

Parameters:

config (ServerConfig) – Server configuration bound to one repository root

Returns:

Zero-argument callable that creates repository API wrappers

Return type:

Callable[[], hubvault.api.HubVaultApi]

build_repo_api_getter

hubvault.server.deps.build_repo_api_getter(api: object | None = None, api_factory: Callable[[], object] | None = None) Callable[[], object][source]

Normalize route-factory repository inputs to one getter callable.

Route factories accept either a concrete API instance for focused tests or a zero-argument factory for production request handling.

Parameters:
  • api (Optional[object]) – Optional concrete API object reused by the route

  • api_factory (Optional[Callable[[], object]]) – Optional factory returning API-like objects

Returns:

Zero-argument callable that yields one API-like object

Return type:

Callable[[], object]

Raises:

TypeError – Raised when both api and api_factory are provided or when neither is provided.

get_token_authorizer

hubvault.server.deps.get_token_authorizer(config) TokenAuthorizer[source]

Build the shared token authorizer for one server app.

Parameters:

config (hubvault.server.config.ServerConfig) – Server configuration carrying normalized token lists

Returns:

Token authorizer bound to the config tokens

Return type:

TokenAuthorizer