This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
from typing import List
|
||||
|
||||
from fastapi import APIRouter
|
||||
|
||||
from src.db.models.bookshelf import Author
|
||||
from src.db.session import SessionDep
|
||||
from src.schema.bookshelf.author import AuthorResponse, to_response
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/authors", response_model=List[AuthorResponse])
|
||||
def get_all_artists(db: SessionDep) -> List[AuthorResponse]:
|
||||
results: List[AuthorResponse] = []
|
||||
authors = db.query(Author).all()
|
||||
for author in authors:
|
||||
response = to_response(author)
|
||||
results.append(response)
|
||||
return results
|
||||
Reference in New Issue
Block a user