Update code in endpoints/store.get.py

This commit is contained in:
Backend IM Bot 2025-03-28 18:10:25 +00:00
parent d8c1e87cd5
commit f4ee838e58

View File

@ -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