Metadata-Version: 2.4
Name: bedrock-fastapi
Version: 0.1.0
Summary: FastAPI integration for Bedrock: request DI scopes, request-bound database sessions, and BedrockExc responses.
Keywords: bedrock,fastapi,starlette,asgi,middleware
Author: maacck
Author-email: maacck <c.mai@madainchina.com>
License-Expression: MIT
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: FastAPI
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Dist: anyio>=3.4.0
Requires-Dist: bedrock-core>=0.3.1
Requires-Dist: starlette>=0.40.0
Requires-Python: >=3.12
Project-URL: Bug Tracker, https://github.com/maacck/bedrock-py/issues
Project-URL: Documentation, https://bedrock-py.com
Project-URL: Homepage, https://bedrock-py.com
Project-URL: Repository, https://github.com/maacck/bedrock-py
Description-Content-Type: text/markdown

# bedrock-fastapi

FastAPI integration for [Bedrock](https://bedrock-py.com). Your application creates and owns the FastAPI app;
this package supplies pieces you add as needed:

- `RequestScopeMiddleware`: one Bedrock DI scope per request.
- `DbSessionMiddleware` / `AsyncDbSessionMiddleware`: each request runs inside `db.session_scope()` /
  `db.asession_scope()`. Services commit; uncommitted work is rolled back when the request ends.
- `bedrock_exception_handler(status_codes)`: answers mapped `BedrockExc` subclasses with `{"detail": ...}`.

```python
from bedrock.exc import BedrockExc
from bedrock_fastapi import AsyncDbSessionMiddleware, RequestScopeMiddleware, bedrock_exception_handler

app.add_middleware(AsyncDbSessionMiddleware)
app.add_middleware(RequestScopeMiddleware)
app.add_exception_handler(BedrockExc, bedrock_exception_handler({ItemNotFound: 404}))
```

See the FastAPI integration docs at https://bedrock-py.com/docs/integrations/fastapi for installation, the
transaction convention, and a complete example.
