diff --git a/README.md b/README.md index 6c67875..439433d 100644 --- a/README.md +++ b/README.md @@ -27,14 +27,14 @@ This repository provides a template for creating and deploying a FastAPI project - Formatting using black - Code quality analysis using SonarQube - Application monitoring using Signoz -- Feature flagging added - User can enabled/disabled +- Feature flagging added - User can enable/disable features - Database Monitoring using percona - Loadtests using locust ### Getting Started #### Requirements: -- Python 3.11 +- Python 3 - Docker - mysql @@ -238,10 +238,9 @@ By following these steps, you'll successfully configure Percona to monitor your #### Dashboard Links - Percona: https://localhost:443 -- flower: http://localhost:5556 -- server: http://localhost:8000 -- locust: http://localhost:8089 -- server-healthcheck: http://localhost:8000/home +- Flower: http://localhost:5556 +- Locust UI: http://localhost:8089 +- Swagger UI: http://localhost:8000 #### Useful scripts diff --git a/app/daos/users.py b/app/daos/users.py index a2af82a..2813691 100644 --- a/app/daos/users.py +++ b/app/daos/users.py @@ -24,6 +24,9 @@ async def get_user(user_id: int, db_session: Session): try: + if not user_id: + raise NoUserFoundException(messages["NO_USER_ID_PROVIDED"]) + cache_key = f"user_{user_id}" cached_user, _ = await CacheUtils.retrieve_cache(cache_key) if cached_user: @@ -119,7 +122,7 @@ def login(data: Login, db_session: Session): ) if not user_details: - raise InvalidCredentialsException(messages["INVALID_CREDENTIALS"]) + raise InvalidCredentialsException(messages["NO_USERS_FOUND_IN_DB"]) if not check_password_hash(user_details.password, user_data["password"]): raise InvalidCredentialsException(messages["INVALID_CREDENTIALS"]) diff --git a/app/routes/__init__.py b/app/routes/__init__.py index dab0049..5aafee4 100644 --- a/app/routes/__init__.py +++ b/app/routes/__init__.py @@ -8,7 +8,7 @@ from .users import user_router api_router = APIRouter() -api_router.include_router(user_router, prefix="/user") +api_router.include_router(user_router, prefix="/users") api_router.include_router(home_router, prefix="/home") api_router.include_router(celery_sample_router, prefix="/celery-sample") api_router.include_router(cache_sample_router, prefix="/cache-sample") diff --git a/app/routes/users/users.py b/app/routes/users/users.py index f582a17..8128918 100644 --- a/app/routes/users/users.py +++ b/app/routes/users/users.py @@ -4,6 +4,7 @@ from fastapi import APIRouter from fastapi import Depends +from fastapi import Path from fastapi.security import HTTPBearer from fastapi_pagination import Page from sqlalchemy.orm import Session @@ -38,7 +39,7 @@ def login(payload: Login, db: Session = Depends(create_local_session)): @user_router.get("/{user_id}", tags=["Users"], dependencies=[Depends(get_current_user)], response_model=UserOutResponse) async def profile( token: Annotated[str, Depends(httpBearerScheme)], - user_id, + user_id: int = Path(..., title="ID of the user"), db: Session = Depends(create_local_session), ): response = await get_user_dao(user_id, db_session=db)