Skip to content

Commit

Permalink
fix - Minor changes of api endpoint + readme file updated
Browse files Browse the repository at this point in the history
  • Loading branch information
anasnadeemws committed Mar 21, 2024
1 parent 9788299 commit d391a9f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion app/daos/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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"])
Expand Down
2 changes: 1 addition & 1 deletion app/routes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
3 changes: 2 additions & 1 deletion app/routes/users/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit d391a9f

Please sign in to comment.