feat: add history api and page

This commit is contained in:
Kentai Radiquum 2024-07-17 12:58:19 +05:00
parent e73b214045
commit eb620c0b1d
Signed by: Radiquum
GPG key ID: 858E8EE696525EED
5 changed files with 186 additions and 22 deletions

19
app/api/history/route.js Normal file
View file

@ -0,0 +1,19 @@
import { NextResponse } from "next/server";
import { fetchDataViaGet } from "../utils";
import { ENDPOINTS } from "../config";
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 });
}
let url = new URL(`${ENDPOINTS.user.history}/${page}`);
url.searchParams.set("token", token);
const response = await fetchDataViaGet(url.toString());
return NextResponse.json(response);
}