mirror of
https://github.com/Radiquum/AniX.git
synced 2025-05-02 02:49:40 +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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue