History Table is now functioning completely
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
"use server";
|
||||
import { NextResponse } from 'next/server';
|
||||
import { getHistory } from '~/server/functions';
|
||||
import { get_history } from '~/server/functions';
|
||||
import { auth } from '~/auth';
|
||||
|
||||
export const GET = async (request: Request) => {
|
||||
try {
|
||||
const url = new URL(request.url);
|
||||
const apiKey = url.searchParams.get('apikey');
|
||||
const userId = Number(url.searchParams.get('user_id')) || -1;
|
||||
const page = Number(url.searchParams.get('page')) || 1;
|
||||
const perPage = Number(url.searchParams.get('per_page')) || 50;
|
||||
if (apiKey !== process.env.API_KEY) {
|
||||
@@ -17,7 +18,7 @@ export const GET = async (request: Request) => {
|
||||
{ status: 401 }
|
||||
);
|
||||
}
|
||||
const historyData = await getHistory(page, perPage);
|
||||
const historyData = await get_history(userId, page, perPage);
|
||||
return NextResponse.json(historyData, { status: 200 });
|
||||
} catch (error) {
|
||||
console.error('Error fetching history data:', error);
|
||||
|
Reference in New Issue
Block a user