quivr/backend/routes/onboarding_routes.py
Zineb El Bachiri 375f50356c
refactor: add modules folder (#1633)
# Description

New Modules folder with "user" module:
- controller: contains the current route
- entity: contains the current Models (TO be renamed DTO)
- repository: contains the current repo
- service: methods used by other modules 

## Checklist before requesting a review

Please delete options that are not relevant.

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented hard-to-understand areas
- [ ] I have ideally added tests that prove my fix is effective or that
my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged

## Screenshots (if appropriate):
2023-11-15 13:17:51 +01:00

46 lines
1.3 KiB
Python

from fastapi import APIRouter, Depends
from middlewares.auth import ( # Assuming you have a get_current_user function
AuthBearer,
get_current_user,
)
from models.databases.supabase.onboarding import (
OnboardingStates,
OnboardingUpdatableProperties,
)
from modules.user.entity.user_identity import UserIdentity
from repository.onboarding.get_user_onboarding import get_user_onboarding
from repository.onboarding.update_user_onboarding import update_user_onboarding
onboarding_router = APIRouter()
@onboarding_router.get(
"/onboarding",
dependencies=[Depends(AuthBearer())],
tags=["Onboarding"],
)
async def get_user_onboarding_handler(
current_user: UserIdentity = Depends(get_current_user),
) -> OnboardingStates | None:
"""
Get user onboarding information for the current user
"""
return get_user_onboarding(current_user.id)
@onboarding_router.put(
"/onboarding",
dependencies=[Depends(AuthBearer())],
tags=["Onboarding"],
)
async def update_user_onboarding_handler(
onboarding: OnboardingUpdatableProperties,
current_user: UserIdentity = Depends(get_current_user),
) -> OnboardingStates:
"""
Update user onboarding information for the current user
"""
return update_user_onboarding(current_user.id, onboarding)