mirror of
https://github.com/Radiquum/AniX.git
synced 2025-05-04 11:59:40 +05:00
feat: add favorites page
This commit is contained in:
parent
484148ada6
commit
28efc5a98c
10 changed files with 177 additions and 36 deletions
26
app/api/favorites/route.js
Normal file
26
app/api/favorites/route.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
import { NextResponse } from "next/server";
|
||||
import { fetchDataViaGet } from "../utils";
|
||||
import { ENDPOINTS } from "../config";
|
||||
import { sort } from "../common";
|
||||
|
||||
|
||||
export async function GET(request) {
|
||||
const page = parseInt(request.nextUrl.searchParams.get(["page"])) || 0;
|
||||
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 (!sort[sortName]) {
|
||||
return NextResponse.json({ message: "Unknown sort" }, { status: 400 });
|
||||
}
|
||||
|
||||
let url = new URL(`${ENDPOINTS.user.favorite}/${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