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

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

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.1.0.tar.gz (13.9 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.1.0-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastapi_lite-1.1.0.tar.gz
  • Upload date:
  • Size: 13.9 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.1.0.tar.gz
Algorithm Hash digest
SHA256 6d59a597ff36ec1c56564807708e83128a632a7c647fddec8df75095d923acf6
MD5 7b7da482c4e7e5608b313267c6e56b1d
BLAKE2b-256 f99632cf9228db80278df0944178ca742ac58b69deea98a25fc80ec857ae221e

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastapi_lite-1.1.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.1.0-py3-none-any.whl.

File metadata

  • Download URL: fastapi_lite-1.1.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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dc93350c9954c64f067e252ac1040981daad935c842c0b88f6048884e7e94983
MD5 8843223230db60a33a1bc863892cfa18
BLAKE2b-256 82dfc69922cd85165ad974265d88f5c26692d5d674c3043ad3e17c4629cb9124

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastapi_lite-1.1.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