mirror of
https://github.com/d3vyce/fastapi-toolsets.git
synced 2026-03-01 17:00:48 +01:00
25 lines
820 B
Python
25 lines
820 B
Python
"""FastAPI utilities package.
|
|
|
|
Provides CRUD operations, fixtures, CLI, and standardized API responses
|
|
for FastAPI with async SQLAlchemy and PostgreSQL.
|
|
|
|
Example usage:
|
|
from fastapi import FastAPI, Depends
|
|
from fastapi_toolsets.exceptions import init_exceptions_handlers
|
|
from fastapi_toolsets.crud import CrudFactory
|
|
from fastapi_toolsets.db import create_db_dependency
|
|
from fastapi_toolsets.schemas import Response
|
|
|
|
app = FastAPI()
|
|
init_exceptions_handlers(app)
|
|
|
|
UserCrud = CrudFactory(User)
|
|
|
|
@app.get("/users/{user_id}", response_model=Response[dict])
|
|
async def get_user(user_id: int, session = Depends(get_db)):
|
|
user = await UserCrud.get(session, [User.id == user_id])
|
|
return Response(data={"user": user.username}, message="Success")
|
|
"""
|
|
|
|
__version__ = "0.6.1"
|