mirror of
https://github.com/Radiquum/AniX.git
synced 2025-04-06 00:04:39 +00:00
feat(backend): add a user favorites route
This commit is contained in:
parent
f535d09e97
commit
332e1d1918
4 changed files with 40 additions and 0 deletions
|
@ -2,6 +2,7 @@ import uvicorn
|
|||
from fastapi import FastAPI
|
||||
from modules import proxy
|
||||
from modules.pages import bookmarks
|
||||
from modules.pages import favorites
|
||||
from modules.pages import index
|
||||
from modules.pages import search
|
||||
from modules.release import release
|
||||
|
@ -25,6 +26,10 @@ TAGS = [
|
|||
"name": "Bookmarks",
|
||||
"description": "Bookmarks API requests",
|
||||
},
|
||||
{
|
||||
"name": "Favorites",
|
||||
"description": "Favorites API requests",
|
||||
},
|
||||
{
|
||||
"name": "Search",
|
||||
"description": "Search API requests",
|
||||
|
@ -47,6 +52,7 @@ app.include_router(release.router, prefix="/api/release", tags=["Releases"])
|
|||
|
||||
app.include_router(index.router, prefix="/api/index", tags=["Index"])
|
||||
app.include_router(bookmarks.router, prefix="/api/bookmarks", tags=["Bookmarks"])
|
||||
app.include_router(favorites.router, prefix="/api/favorites", tags=["Favorites"])
|
||||
app.include_router(search.router, prefix="/api/search", tags=["Search"])
|
||||
|
||||
app.include_router(proxy.router, prefix="/api/proxy")
|
||||
|
|
33
backend/modules/pages/favorites.py
Normal file
33
backend/modules/pages/favorites.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
from fastapi import APIRouter
|
||||
from fastapi import Request
|
||||
from modules.proxy import apiRequest
|
||||
from modules.proxy import ENDPOINTS
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("", summary="Get user favorites list")
|
||||
async def GetUserFavorites(request: Request, token: str, page: int = 0):
|
||||
return await apiRequest(
|
||||
request, ENDPOINTS["user"]["favorite"], f"/all/{page}", query=f"?token={token}"
|
||||
)
|
||||
|
||||
|
||||
@router.get("/list/{release_id}/add", summary="Add release to user favorites")
|
||||
async def addReleaseToFavorites(request: Request, release_id: int, token: str):
|
||||
return await apiRequest(
|
||||
request,
|
||||
ENDPOINTS["user"]["favorite"],
|
||||
f"/add/{release_id}",
|
||||
query=f"?token={token}",
|
||||
)
|
||||
|
||||
|
||||
@router.get("/list/{release_id}/delete", summary="Remove release from user favorites")
|
||||
async def deleteReleaseFromFavorites(request: Request, release_id: int, token: str):
|
||||
return await apiRequest(
|
||||
request,
|
||||
ENDPOINTS["user"]["favorite"],
|
||||
f"/delete/{release_id}",
|
||||
query=f"?token={token}",
|
||||
)
|
|
@ -33,6 +33,7 @@ ENDPOINTS: Endpoints = {
|
|||
"watched": f"{API_URL}/profile/list/all/3",
|
||||
"delayed": f"{API_URL}/profile/list/all/4",
|
||||
"abandoned": f"{API_URL}/profile/list/all/5",
|
||||
"favorite": f"{API_URL}/favorite",
|
||||
},
|
||||
"search": f"{API_URL}/search/releases",
|
||||
"statistic": {
|
||||
|
|
Loading…
Add table
Reference in a new issue