From f4ee838e5899adb54e30b098723fcbfa103b1671 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Fri, 28 Mar 2025 18:10:25 +0000 Subject: [PATCH] Update code in endpoints/store.get.py --- endpoints/store.get.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/endpoints/store.get.py b/endpoints/store.get.py index 40b0ea3..78c93a9 100644 --- a/endpoints/store.get.py +++ b/endpoints/store.get.py @@ -1,13 +1,21 @@ from fastapi import APIRouter, Depends, HTTPException, status +from sqlalchemy.orm import Session from typing import List +from core.database import get_db from models.country import Country from schemas.country import CountrySchema from helpers.country_helpers import get_asian_countries router = APIRouter() -@router.get("/store", response_model=List[CountrySchema], status_code=200) -async def get_asian_countries_list(): - """Get list of countries in Asia""" - countries = get_asian_countries() +@router.get("/store", response_model=List[CountrySchema]) +async def get_asian_countries_list( + db: Session = Depends(get_db) +): + countries = get_asian_countries(db) + if not countries: + raise HTTPException( + status_code=status.HTTP_404_NOT_FOUND, + detail="No Asian countries found" + ) return countries \ No newline at end of file