cakey-7k997a/endpoints/store.get.py
2025-03-28 18:10:25 +00:00

21 lines
659 B
Python

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])
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