Metadata-Version: 2.1
Name: transaction-middleware
Version: 0.1.5
Summary: Async Transaction Middleware for FastAPI/Starlette
Home-page: https://impalah.github.io/transaction-middleware/
License: MIT
Keywords: transaction,middleware,fastapi,starlette
Author: impalah
Author-email: impalah@gmail.com
Requires-Python: >=3.10
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: FastAPI
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
Classifier: Topic :: Internet :: WWW/HTTP :: Session
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Dist: fastapi (>=0.105.0)
Requires-Dist: loguru (>=0.7.2)
Requires-Dist: pydantic[email] (>=2.5.3)
Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
Requires-Dist: svix-ksuid (>=0.6.2)
Project-URL: Documentation, https://impalah.github.io/transaction-middleware/
Project-URL: Repository, https://github.com/impalah/transaction-middleware
Project-URL: Source, https://github.com/impalah/transaction-middleware
Description-Content-Type: text/markdown

# transaction-middleware

Async Transaction Middleware for FastAPI/Starlette.

## Installation

Using pip:

```bash
pip install transaction-middleware
```

Using poetry

```bash
poetry add transaction-middleware
```


## How to use it

Transaction Middleware follows the middleware protocol and, therefore, should be added as a middleware to your FastApi or Starlette application.

The steps, using FastAPI:

```python

from fastapi import FastAPI, Depends

from starlette.requests import Request
from starlette.responses import Response


```

Then set the environment variables (or your .env file)

```bash

```

Call the method

```bash
curl -X GET http://localhost:8000/ -H "Authorization: Bearer MY_ID_TOKEN"
```


## Middleware configuration

The middleware configuration is done by environment variables (or using and .env file if your project uses python-dotenv).

The main variables are shown in the table below:

| Name | Description | Values | Default |
| --------- | --------- | --------- | --------- |
| TRANSACTION_MIDDLEWARE_LOG_LEVEL | Log level for the application | DEBUG, INFO, WARNING, ERROR, CRITICAL | INFO |
| TRANSACTION_MIDDLEWARE_LOG_FORMAT | Log format | See python logger documentation | %(log_color)s%(levelname)-9s%(reset)s %(asctime)s %(name)s %(message)s |
| TRANSACTION_MIDDLEWARE_HEADER | Name for the header | Any String | X-Transaction-ID |




