Skip to content

Commit

Permalink
feat: api stats should be GET and not POST
Browse files Browse the repository at this point in the history
  • Loading branch information
rtaieb committed Dec 27, 2024
1 parent 58770c6 commit 698b1c1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/app/api/stats/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ type StatOuput = {
stats: StatOutputRecord[];
};

export async function POST(request: NextRequest) {
const requestBody = await request.json();
const parsedRequest = StatsRouteSchema.safeParse(requestBody);
export async function GET(request: NextRequest) {
const parsedRequest = StatsRouteSchema.safeParse({
since: +(request.nextUrl.searchParams.get("since") ?? 0),
periodicity: request.nextUrl.searchParams.get("periodicity"),
});
if (!parsedRequest.success) {
const { errors } = parsedRequest.error;
return NextResponse.json({ error: { message: "Invalid request", errors } }, { status: 400 });
Expand Down

0 comments on commit 698b1c1

Please sign in to comment.