Skip to content

Dependencies

dependencies

FastAPI request-scoped dependencies that bridge transport concerns (headers) to the domain layer

ensure_profile_exists(profile_id=Depends(get_profile_id_from_header)) async

Dependency that requires X-Profile-ID and ensures the profile exists

Implicitly creates the profile when it doesn't exist yet

Parameters:

Name Type Description Default
profile_id str

Profile id from the header

Depends(get_profile_id_from_header)

Returns:

Type Description
str

The validated profile id

Raises:

Type Description
HTTPException

If the X-Profile-ID header is missing

DatabaseError

If the profile can't be read or created

get_job_manager(request)

Endpoint dependency returning the lifespan-scoped JobQueueManager

Parameters:

Name Type Description Default
request Request

The FastAPI.Request object

required

Returns:

Type Description
JobQueueManager

The single JobQueueManager built during application startup

get_processor(request)

Endpoint dependency returning the lifespan-scoped Processor

Parameters:

Name Type Description Default
request Request

The FastAPI.Request object

required

Returns:

Type Description
Processor

The single Processor instance built during application startup

get_profile_id_from_header(x_profile_id=Header(None)) async

Extracts the X-Profile-ID header, if present

Parameters:

Name Type Description Default
x_profile_id str

The X-Profile-ID Header

Header(None)

Returns:

Type Description
str | None

The Header value, or None when absent

get_profile_id_optional(profile_id=Depends(get_profile_id_from_header)) async

Dependency that returns the profile id when present, ensuring it exists

Parameters:

Name Type Description Default
profile_id str

Profile id from the header

Depends(get_profile_id_from_header)

Returns:

Type Description
str | None

The validated profile id, or None when the header is absent

Raises:

Type Description
DatabaseError

If the profile can't be read or created