Skip to content

Commit

Permalink
Server route to generate Merkle Root (#234)
Browse files Browse the repository at this point in the history
Why:
* So we can call this to get a merkle root whenever we need to, for
testing purposes

How:
* Adding `const revalidate = 0` to prevent NextJS cache
* Adding the needed env vars to the Github Actions workflow
  • Loading branch information
DavideSilva authored May 3, 2024
1 parent faba49a commit a6a0ea7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/web-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ jobs:
run: yarn workspace @discovery-dao/web-app build
env:
NEXT_PUBLIC_WC_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_WC_PROJECT_ID }}
NEXT_CITIZEND_WALLET_PRIVATE_KEY: ${{ secrets.NEXT_CITIZEND_WALLET_PRIVATE_KEY }}
NEXT_PUBLIC_IDOS_NODE_URL: ${{ secrets.NEXT_PUBLIC_IDOS_NODE_URL }}
24 changes: 13 additions & 11 deletions packages/web-app/app/api/generate/route.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { generateMerkleRoot } from "@/app/_server/projects/generate-merkle-root";

export const revalidate = 0;

export async function GET(_request: Request) {
// const root = await generateMerkleRoot();
//
// if (typeof root === 'object' && 'error' in root) {
// return new Response(`Generate root error: ${root.error}`, {
// status: 500,
// });
// }
//
// return Response.json(root);

return new Response('root');
const root = await generateMerkleRoot();

if (typeof root === 'object' && 'error' in root) {
return new Response(`Generate root error: ${root.error}`, {
status: 500,
});
}

return Response.json(root);
}

0 comments on commit a6a0ea7

Please sign in to comment.