Update API names now that I can update iOS App

This commit is contained in:
gib
2024-07-25 21:49:38 -05:00
parent f6af2ff738
commit a849b065a1
4 changed files with 2 additions and 13 deletions
@@ -0,0 +1,25 @@
"use server";
import { NextResponse } from 'next/server';
import { getHistory } from '~/server/functions';
export const GET = async (request: Request) => {
try {
const url = new URL(request.url);
const apiKey = url.searchParams.get('apikey');
const page = Number(url.searchParams.get('page')) || 1;
if (apiKey !== process.env.API_KEY)
return NextResponse.json(
{ message: 'Unauthorized' },
{ status: 401 }
);
const perPage = 50;
const historyData = await getHistory(page, perPage);
return NextResponse.json(historyData, { status: 200 });
} catch (error) {
console.error('Error fetching history data:', error);
return NextResponse.json(
{ message: 'Internal server error' },
{ status: 500 }
);
}
};