1 comment

[ 3.6 ms ] story [ 72.6 ms ] thread
Litestar is a Faster yet more fullstack alternative to FastAPI and Comparable to Django in terms of Async API Framework.

2.0 comes with :

- HTMX support

- All new DTOs, with support for dataclasses, Pydantic, attrs, msgspec and SQLAlchemy, allowing easy on-the-fly data transformation, greatly reducing the boilerplate needed to set up validation and serialisation schemas

- SQLAlchemy repositories, providing a synchronous and asynchronous implementation of common CRUD and highly optimised bulk operations, with extensive support and testing for SQLite, Postgres, Oracle, MySQL/MariaDB, DuckDB and Spanner

- SQLAlchemy integration including session management and serialisation/validation, enabling you to directly return SQLAlchemy models from route handlers without the need for intermediary models

- Full support for validation and serialisation of attrs classes and msgspec Structs. Where previously only Pydantic models and types where supported, you can now mix and match any of these three libraries. In addition to this, adding support for another modelling library has been greatly simplified with the new plugin architecture

- Removal of Pydantic as a required dependency; Pydantic is now fully optional, while still being supported in the same capacity as before

- Channels, a general purpose event streaming module, featuring inter-process communication and WebSockets integration

- Unified storage interfaces. All internals (sessions, caches, middlewares) have been moved to the new Stores; low-level, asynchronous key/value stores. They are managed and accessible through a registry, and offer fine grained, centralised control over how and where your application stores data

- Enhanced WebSockets support, including automatic connection handling, validation of incoming and serialisation of outgoing data, providing feature parity with route handlers and controllers, including full DTO support, OOP based event dispatching and enabling the handling of WebSockets with synchronous functions.

- Server-sent events