Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

All notable changes to this project will be documented in this file.

## [1.2.1] - 2026-04-24

### 🚀 Features
- **Built-in FastAPI Response**: Added `BFastResponse` directly to the `b_fast` package for easier integration.
- **Improved Type Support**: Better handling of `BFastError` and updated `BFastResponse` to use built-in encoder.

### 🔧 Fixes
- **Module Visibility**: Fixed `ModuleNotFoundError`/`ImportError` when using the library in external projects by correctly exporting `BFast` in `__init__.py`.
- **Typings Organization**: Moved and renamed `.pyi` file to `python/b_fast/_b_fast.pyi` to ensure correct recognition by IDEs and type checkers after installation.
- **FastAPI Dependency**: Updated `README` to recommend installation with `[fastapi]` extra for projects using FastAPI.

### 📚 Documentation
- Updated `README` with simplified FastAPI usage example.
- Fixed installation instructions for better clarity.

## [1.1.0] - 2026-02-07

### 🚀 Features
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "b_fast"
version = "1.2.0"
version = "1.2.1"
edition = "2021"

[lib]
Expand Down
29 changes: 13 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,17 @@ Complete test including network transfer and deserialization (10,000 objects):

### Backend (Python)
```bash
uv add bfast-py
# Basic installation
pip install bfast-py

# With FastAPI support
pip install "bfast-py[fastapi]"
```
or
or with `uv`:
```bash
pip install bfast-py
uv add bfast-py
# or
uv add "bfast-py[fastapi]"
```

### Frontend (TypeScript)
Expand All @@ -81,22 +87,12 @@ npm install bfast-client
### Backend (Python)

#### 1. FastAPI (Direct Integration) ⭐ Recommended
B-FAST integrates seamlessly as a response class.
B-FAST includes a built-in `BFastResponse` for seamless integration.

```python
from fastapi import FastAPI, Response
from fastapi import FastAPI
from pydantic import BaseModel
import b_fast

class BFastResponse(Response):
media_type = "application/x-bfast"

def __init__(self, content=None, *args, **kwargs):
super().__init__(content, *args, **kwargs)
self.encoder = b_fast.BFast()

def render(self, content) -> bytes:
return self.encoder.encode_packed(content, compress=True)
from b_fast import BFastResponse

app = FastAPI()

Expand All @@ -106,6 +102,7 @@ class User(BaseModel):

@app.get("/users", response_class=BFastResponse)
async def get_users():
# Returns binary B-FAST data with automatic LZ4 compression
return [User(id=i, name=f"User {i}") for i in range(1000)]
```

Expand Down
30 changes: 26 additions & 4 deletions client-ts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion client-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@
"lz4js": "^0.2.0"
},
"devDependencies": {
"@types/node": "^25.6.0",
"typescript": "^5.0.0"
},
"engines": {
"node": ">=14.0.0"
}
}
}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "maturin"

[project]
name = "bfast-py"
version = "1.2.0"
version = "1.2.1"
description = "⚡ B-FAST (Binary Fast Adaptive Serialization Transfer) - Protocolo de serialização binária de ultra-alta performance, desenvolvido em Rust para o ecossistema Python e TypeScript"
readme = "README.md"
requires-python = ">=3.8"
Expand Down
6 changes: 3 additions & 3 deletions python/b_fast/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
Ultra-fast binary serialization library with Rust backend.
"""

from ._b_fast import BFast
from ._b_fast import BFast, BFastError
from .integration import BFastResponse

__version__ = "1.2.0"
__all__ = ["BFast", "BFastResponse"]
__version__ = "1.2.1"
__all__ = ["BFast", "BFastError", "BFastResponse"]
File renamed without changes.
4 changes: 2 additions & 2 deletions python/b_fast/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ class BFastResponse(Response):
def __init__(self, content: Any, **kwargs):
if not FASTAPI_AVAILABLE:
raise ImportError(
"FastAPI is required to use BFastResponse. Install it with 'pip install fastapi'."
"FastAPI is required to use BFastResponse. Install it with 'pip install bfast-py[fastapi]'."
)

# Delayed import to avoid circular dependency
from ._b_fast import BFast

super().__init__(content=content, **kwargs)
self.encoder = BFast()
super().__init__(content=content, **kwargs)

def render(self, content: Any) -> bytes:
return self.encoder.encode_packed(content, compress=True)
Loading