Skip to main content

Reusable FastAPI utilities: AWS helpers, SQLite cache, and uvicorn-style access logging

Project description

fastapi-lite

Reusable FastAPI utilities extracted for shared use: AWS helpers (boto3 session, botocore models, SSO auth), SQLite-backed cache, and uvicorn-style access logging.

Installation

pip install fastapi-lite

With AWS support (boto3, aws_sso_lite, httplite):

pip install fastapi-lite[aws]

Modules

fastapi_lite.log — Access logging

Drop-in uvicorn-style HTTP access-log middleware:

from fastapi import FastAPI
from fastapi_lite.log import add_uvicorn_like_access_log

app = FastAPI()
add_uvicorn_like_access_log(app)

fastapi_lite.cache — SQLite cache

Namespace-based SQLite cache with TTL, plus a ready-to-include FastAPI router:

from pathlib import Path
from fastapi_lite.cache import CacheManager, CacheStore, router as cache_router, set_cache_manager

# Optionally configure cache directory (defaults to ~/.fastapi_lite/cache)
set_cache_manager(CacheManager(Path.home() / ".myapp" / "cache"))

app.include_router(cache_router)

Use the store directly:

from fastapi_lite.cache import CacheManager
from pathlib import Path

manager = CacheManager(Path("/tmp/cache"))
store = manager.get_store("my-namespace")
store.set_item("key", {"hello": "world"}, ttl_ms=60000)
print(store.get_item("key"))

fastapi_lite.aws — AWS helpers

Requires the aws extra: pip install fastapi-lite[aws]

from fastapi_lite.aws import (
    get_boto3_session,
    execute_aws_action,
    BotoJSONEncoder,
    set_aws_sso_config,
    botocore_router,
    aws_router,
    auth_router,
)

# Configure SSO (call once at startup)
set_aws_sso_config([
    {
        "ssoRegion": "eu-west-1",
        "ssoStartUrl": "https://d-xxx.awsapps.com/start",
        "domain": "aws.amazon.com",
        "instance": "aws",
    }
])

# Include routers
app.include_router(botocore_router)
app.include_router(aws_router)
app.include_router(auth_router)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_lite-1.0.0.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastapi_lite-1.0.0-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_lite-1.0.0.tar.gz.

File metadata

  • Download URL: fastapi_lite-1.0.0.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fastapi_lite-1.0.0.tar.gz
Algorithm Hash digest
SHA256 33bd2f9724e1b8f1e3f8aa7bdac9220116164cb2a01314982b65135267c98cf0
MD5 63752118519eacc5d3a3b75c1ea5b391
BLAKE2b-256 ac2a8fe8125d1c951ab8e14daca3751db8d25cdd97f12828106b8f65f37e8741

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastapi_lite-1.0.0.tar.gz:

Publisher: python-publish.yml on kejun91/fastapi-lite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastapi_lite-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: fastapi_lite-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fastapi_lite-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e2b4139ca344cf9304ebf1ab4f83db766a2e892dbafc42593a01241e73274509
MD5 a2db3bdd9cd8be96603188774c102389
BLAKE2b-256 0ada73898d8f69aca20d7f3ea4e3d14eef96caa06a200a75a084eac5a8a13835

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastapi_lite-1.0.0-py3-none-any.whl:

Publisher: python-publish.yml on kejun91/fastapi-lite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page