Skip to content

Commit

Permalink
πŸ’» mocked rounds routes (#243)
Browse files Browse the repository at this point in the history
* πŸ’» add rf/rounds

* πŸ’» add /rf/rounds/id route

* ✨ prettier
  • Loading branch information
Flip-Liquid committed Apr 22, 2024
1 parent 62948be commit 0d9d15f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/app/api/common/rounds/getRetroFundingRounds.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { cache } from "react";

async function getRetroFundingRound(roundId: string) {
const defaultEvents = [
{
status: "PLANNED",
timestamp: "2024-01-01T00:00:00Z",
},
{
status: "SCHEDULED",
timestamp: "2024-02-01T00:00:00Z",
},
{
status: "DONE",
timestamp: "2024-03-01T00:00:00Z",
},
];
const defaultround = {
roundId: 3,
name: "RetroPGF Round Three",
description: "The third retroactive funding round",
externalLink: "https://vote.optimism.io/retropgf/3/summary",
events: defaultEvents,
};

return defaultround;
}

export const fetchRetroFundingRounds = cache(getRetroFundingRound);
13 changes: 13 additions & 0 deletions src/app/api/v1/retrofunding/rounds/[roundId]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { NextResponse, type NextRequest } from "next/server";
import { fetchRetroFundingRounds } from "@/app/api/common/rounds/getRetroFundingRounds";

export async function GET(
request: NextRequest,
route: { params: { roundId: string } }
) {
const { roundId } = route.params;
const round = await fetchRetroFundingRounds(roundId);
return new Response(JSON.stringify(round), {
status: 200,
});
}

0 comments on commit 0d9d15f

Please sign in to comment.