mirror of
https://github.com/Radiquum/AniX.git
synced 2025-04-29 01:19:41 +05:00
feat: add bookmarks & bookmarks category pages
This commit is contained in:
parent
a3f5f2e116
commit
bccc8407fc
13 changed files with 624 additions and 155 deletions
50
app/api/bookmarks/route.js
Normal file
50
app/api/bookmarks/route.js
Normal file
|
@ -0,0 +1,50 @@
|
|||
import { NextResponse } from "next/server";
|
||||
import { fetchDataViaGet } from "../utils";
|
||||
import { ENDPOINTS } from "../config";
|
||||
|
||||
const list = {
|
||||
watching: 1,
|
||||
planned: 2,
|
||||
watched: 3,
|
||||
delayed: 4,
|
||||
abandoned: 5,
|
||||
};
|
||||
|
||||
const sort = {
|
||||
adding_descending: 1,
|
||||
adding_ascending: 2,
|
||||
// year_descending: 3,
|
||||
// year_ascending: 4,
|
||||
alphabet_descending: 5,
|
||||
alphabet_ascending: 6,
|
||||
};
|
||||
|
||||
export async function GET(request) {
|
||||
const page = parseInt(request.nextUrl.searchParams.get(["page"])) || 0;
|
||||
const listName = request.nextUrl.searchParams.get(["list"]) || null;
|
||||
const token = request.nextUrl.searchParams.get(["token"]) || null;
|
||||
const sortName = request.nextUrl.searchParams.get(["sort"]) || "adding_descending";
|
||||
|
||||
if (!token || token == "null") {
|
||||
return NextResponse.json({ message: "No token provided" }, { status: 403 });
|
||||
}
|
||||
|
||||
if (!listName || listName == "null") {
|
||||
return NextResponse.json({ message: "No list provided" }, { status: 400 });
|
||||
}
|
||||
|
||||
if (!list[listName]) {
|
||||
return NextResponse.json({ message: "Unknown list" }, { status: 400 });
|
||||
}
|
||||
|
||||
if (!sort[sortName]) {
|
||||
return NextResponse.json({ message: "Unknown sort" }, { status: 400 });
|
||||
}
|
||||
|
||||
let url = new URL(`${ENDPOINTS.user.bookmark}/${list[listName]}/${page}`);
|
||||
url.searchParams.set("token", token);
|
||||
url.searchParams.set("sort", sort[sortName]);
|
||||
|
||||
const response = await fetchDataViaGet(url.toString());
|
||||
return NextResponse.json(response);
|
||||
}
|
|
@ -7,18 +7,23 @@ export const ENDPOINTS = {
|
|||
info: `${API_URL}/release`,
|
||||
episode: `${API_URL}/episode`,
|
||||
},
|
||||
profile: `${API_URL}/profile`,
|
||||
filter: `${API_URL}/filter`,
|
||||
auth: `${API_URL}/auth/signIn`,
|
||||
user: {
|
||||
profile: `${API_URL}/profile`,
|
||||
bookmark: `${API_URL}/profile/list/all`,
|
||||
history: `${API_URL}/history`,
|
||||
watching: `${API_URL}/profile/list/all/1`,
|
||||
planned: `${API_URL}/profile/list/all/2`,
|
||||
watched: `${API_URL}/profile/list/all/3`,
|
||||
delayed: `${API_URL}/profile/list/all/4`,
|
||||
abandoned: `${API_URL}/profile/list/all/5`,
|
||||
favorite: `${API_URL}/favorite`,
|
||||
},
|
||||
filter: `${API_URL}/filter`,
|
||||
auth: `${API_URL}/auth/signIn`,
|
||||
// user: {
|
||||
// history: `${API_URL}/history`,
|
||||
// watching: `${API_URL}/profile/list/all/1`,
|
||||
// planned: `${API_URL}/profile/list/all/2`,
|
||||
// watched: `${API_URL}/profile/list/all/3`,
|
||||
// delayed: `${API_URL}/profile/list/all/4`,
|
||||
// abandoned: `${API_URL}/profile/list/all/5`,
|
||||
// favorite: `${API_URL}/favorite`,
|
||||
// },
|
||||
search: `${API_URL}/search/releases`,
|
||||
statistic: {
|
||||
addHistory: `${API_URL}/history/add`,
|
||||
|
|
0
app/api/mappings.js
Normal file
0
app/api/mappings.js
Normal file
|
@ -4,7 +4,7 @@ import { ENDPOINTS } from "@/app/api/config";
|
|||
|
||||
export async function GET(request, params) {
|
||||
const token = request.nextUrl.searchParams.get(["token"]) || null;
|
||||
let url = new URL(`${ENDPOINTS.profile}/${params["params"]["id"]}`);
|
||||
let url = new URL(`${ENDPOINTS.user.profile}/${params["params"]["id"]}`);
|
||||
if (token) {
|
||||
url.searchParams.set("token", token);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue