I am trying to figure out how to make configuration/singleton available to different module. Perhaps there is a standard Python way of doing this that I don't know yet. So I create a configuration singleton that has all the app configurations and want to 'share' this with all modules. Same use-case would apply to sharing DB connection.
main.py
app = FastApi()
config = some_config_object_from_somewhere()
app.include_router(
collection.router,
prefix='/api/collection'
)
api/collection.py
router = APIRouter()
@router.post("/", status_code=201)
async def collect():
# I want to use config that is created/defined in main.py
# HOW? I thought dependency injection that is built into FastAPI would
# help, but can't seem to define something in a different module and have it
# available in the 'router' module