Skip to content

Commit

Permalink
Hook up db items to api endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Flexicon committed Mar 26, 2023
1 parent e7c489e commit f2077a2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
7 changes: 3 additions & 4 deletions api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
from starlette.middleware.cors import CORSMiddleware

from api.handlers import get_comps_handler, get_champions_handler, get_items_handler
from cdragon.items import Item as CDragonItem
from common.db import DB
from common.models import Champion, Comp
from common.models import Champion, Comp, CompositeItem

load_dotenv()
app = FastAPI()
Expand All @@ -30,7 +29,7 @@ class CompResponse(Comp):
pass


class ItemResponse(CDragonItem):
class ItemResponse(CompositeItem):
pass


Expand Down Expand Up @@ -61,4 +60,4 @@ async def get_champions():

@app.get("/items", response_model=List[ItemResponse])
async def get_items():
return get_items_handler()
return get_items_handler(db.get_items_collection())
8 changes: 3 additions & 5 deletions api/handlers/get_items_handler.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from typing import List
from pymongo.collection import Collection

from cdragon.items import Item, get_items


def handler() -> List[Item]:
return get_items()
def handler(items: Collection):
return list(items.find())

0 comments on commit f2077a2

Please sign in to comment.