refactor(backend-&-frontend): change bookmarks api urls to /api/bookmarks/{path} from /api/favorites/{path}

BREAKING CHANGE:
This commit is contained in:
Kentai Radiquum 2024-05-01 11:49:07 +05:00
parent 278d0ec1f2
commit f535d09e97
Signed by: Radiquum
GPG key ID: 858E8EE696525EED
6 changed files with 40 additions and 34 deletions

View file

@ -1,7 +1,7 @@
import uvicorn import uvicorn
from fastapi import FastAPI from fastapi import FastAPI
from modules import proxy from modules import proxy
from modules.pages import favorites from modules.pages import bookmarks
from modules.pages import index from modules.pages import index
from modules.pages import search from modules.pages import search
from modules.release import release from modules.release import release
@ -22,8 +22,8 @@ TAGS = [
"description": "Releases API requests", "description": "Releases API requests",
}, },
{ {
"name": "Favorites", "name": "Bookmarks",
"description": "Favorites API requests", "description": "Bookmarks API requests",
}, },
{ {
"name": "Search", "name": "Search",
@ -46,7 +46,7 @@ app.include_router(auth.router, prefix="/api/auth", tags=["Profile"])
app.include_router(release.router, prefix="/api/release", tags=["Releases"]) app.include_router(release.router, prefix="/api/release", tags=["Releases"])
app.include_router(index.router, prefix="/api/index", tags=["Index"]) app.include_router(index.router, prefix="/api/index", tags=["Index"])
app.include_router(favorites.router, prefix="/api/favorites", tags=["Favorites"]) app.include_router(bookmarks.router, prefix="/api/bookmarks", tags=["Bookmarks"])
app.include_router(search.router, prefix="/api/search", tags=["Search"]) app.include_router(search.router, prefix="/api/search", tags=["Search"])
app.include_router(proxy.router, prefix="/api/proxy") app.include_router(proxy.router, prefix="/api/proxy")

View file

@ -46,3 +46,30 @@ async def GetUserAbandoned(request: Request, token: str, page: int = 0):
return await apiRequest( return await apiRequest(
request, ENDPOINTS["user"]["abandoned"], page, query=f"?token={token}" request, ENDPOINTS["user"]["abandoned"], page, query=f"?token={token}"
) )
@router.get(
"/list/{bookmark_list_id}/{release_id}/add", summary="Add release to bookmarks list"
)
async def addReleaseToBookmarks(
request: Request, release_id: int, bookmark_list_id: int, token: str
):
return await apiRequest(
request,
f"{ENDPOINTS['profile']}/list/add/{bookmark_list_id}/{release_id}",
query=f"?token={token}",
)
@router.get(
"/list/{bookmark_list_id}/{release_id}/delete",
summary="Remove release from bookmarks list",
)
async def deleteReleaseFromBookmarks(
request: Request, release_id: int, bookmark_list_id: int, token: str
):
return await apiRequest(
request,
f"{ENDPOINTS['profile']}/list/delete/{bookmark_list_id}/{release_id}",
query=f"?token={token}",
)

View file

@ -28,25 +28,3 @@ async def getUserById(
}, },
"is_my_profile": res["is_my_profile"], "is_my_profile": res["is_my_profile"],
} }
@router.get("/{release_id}/{list}/add", summary="Add release to bookmarks list")
async def addReleaseToBookmarks(
request: Request, release_id: int, list: int, token: str
):
return await apiRequest(
request,
f"{ENDPOINTS['profile']}/list/add/{list}/{release_id}",
query=f"?token={token}",
)
@router.get("/{release_id}/{list}/delete", summary="Remove release from bookmarks list")
async def deleteReleaseFromBookmarks(
request: Request, release_id: int, list: int, token: str
):
return await apiRequest(
request,
f"{ENDPOINTS['profile']}/list/delete/{list}/{release_id}",
query=f"?token={token}",
)

View file

@ -11,13 +11,14 @@ export const endpoints = {
user: { user: {
profile: `${API_URL}/profile`, profile: `${API_URL}/profile`,
auth: `${API_URL}/auth`, auth: `${API_URL}/auth`,
history: `${API_URL}/favorites/history`,
bookmarks: { bookmarks: {
watching: `${API_URL}/favorites/watching`, list: `${API_URL}/bookmarks/list`,
planned: `${API_URL}/favorites/planned`, history: `${API_URL}/bookmarks/history`,
watched: `${API_URL}/favorites/watched`, watching: `${API_URL}/bookmarks/watching`,
delayed: `${API_URL}/favorites/delayed`, planned: `${API_URL}/bookmarks/planned`,
abandoned: `${API_URL}/favorites/abandoned`, watched: `${API_URL}/bookmarks/watched`,
delayed: `${API_URL}/bookmarks/delayed`,
abandoned: `${API_URL}/bookmarks/abandoned`,
}, },
}, },
release: `${API_URL}/release`, release: `${API_URL}/release`,

View file

@ -46,7 +46,7 @@ export const ReleaseInfo = (props) => {
useEffect(() => { useEffect(() => {
async function _setList() { async function _setList() {
const url = `${endpoints.user.profile}/${props.id}/${list}/add?token=${userStore.token}`; const url = `${endpoints.user.bookmarks.list}/${list}/${props.id}/add?token=${userStore.token}`;
await getData(url); await getData(url);
} }
if ( if (

View file

@ -17,7 +17,7 @@ export default function History() {
async function fetchData(page = 0) { async function fetchData(page = 0) {
if (userStore.token) { if (userStore.token) {
const url = `${endpoints.user.history}?page=${page}&token=${userStore.token}`; const url = `${endpoints.user.bookmarks.history}?page=${page}&token=${userStore.token}`;
const data = await getData(url); const data = await getData(url);
if (data.content.length < 25) { if (data.content.length < 25) {