Skip to content

Commit

Permalink
Merge pull request #145 from penumbra-zone/fix-dynamic-segments
Browse files Browse the repository at this point in the history
Fix dynamic route segments for production deployment
  • Loading branch information
ejmg authored Jul 25, 2024
2 parents ba609b3 + 8260137 commit a1157d0
Show file tree
Hide file tree
Showing 19 changed files with 20 additions and 21 deletions.
3 changes: 1 addition & 2 deletions src/app/api/block/route.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
export const dynamic = "force-dynamic";
import { sql } from "@pgtyped/runtime";
import { getPgClient } from "@/lib/db";
import { IGetBlockQuery } from "./route.types";
import { BlockHeightValidator } from "@/lib/validators/search";
import { z } from "zod";

export const dynamic = "force-dynamic";

export async function GET(req: Request) {
console.log("Sucess: GET /api/block");
try {
Expand Down
4 changes: 1 addition & 3 deletions src/app/api/blocks/route.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
export const dynamic = "force-dynamic";
import { sql } from "@pgtyped/runtime";
import { IGetBlocksByDescQuery, IGetBlocksCountQuery} from "./route.types";
import { getPgClient } from "@/lib/db";

// Without forcing no-cache on the route, even downstream components will render stale data without a hard-refresh of the page. This holds true for /transactions as well.
export const dynamic = "force-dynamic";

export async function POST(req: Request) {
console.log("POST req on /api/blocks/");
try {
Expand Down
1 change: 1 addition & 0 deletions src/app/api/ibc/channel/route.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const dynamic = "force-dynamic";
import { type NextRequest } from "next/server";
import { getPgClient } from "@/lib/db";
import { sql } from "@pgtyped/runtime";
Expand Down
1 change: 1 addition & 0 deletions src/app/api/ibc/channels/route.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const dynamic = "force-dynamic";
import { getPgClient } from "@/lib/db";
import { sql } from "@pgtyped/runtime";
import { IGetChannelsCountQuery, IGetIbcChannelsQuery } from "./route.types";
Expand Down
1 change: 1 addition & 0 deletions src/app/api/ibc/client/route.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const dynamic = "force-dynamic";
import { type NextRequest } from "next/server";
import { getPgClient } from "@/lib/db";
import { sql } from "@pgtyped/runtime";
Expand Down
1 change: 1 addition & 0 deletions src/app/api/ibc/clients/route.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const dynamic = "force-dynamic";
import { getPgClient } from "@/lib/db";
import { sql } from "@pgtyped/runtime";
import { NextRequest } from "next/server";
Expand Down
1 change: 1 addition & 0 deletions src/app/api/ibc/connection/route.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const dynamic = "force-dynamic";
import { getPgClient } from "@/lib/db";
import { sql } from "@pgtyped/runtime";
import { type NextRequest } from "next/server";
Expand Down
1 change: 1 addition & 0 deletions src/app/api/ibc/connections/route.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const dynamic = "force-dynamic";
import { getPgClient } from "@/lib/db";
import { sql } from "@pgtyped/runtime";
import { IGetConnectionsCountQuery, IGetConnectionsQuery } from "./route.types";
Expand Down
4 changes: 1 addition & 3 deletions src/app/api/transaction/route.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
export const dynamic = "force-dynamic";
import { getPgClient } from "@/lib/db";
import { sql } from "@pgtyped/runtime";
import { IGetTransactionQuery } from "./route.types";
import { transactionFromBytes, ibcRegistry } from "@/lib/protobuf";
import { HashResultValidator } from "@/lib/validators/search";
import { z } from "zod";
// import { } from "@buf/cosmos_ibc.bufbuild_es/ibc/core/client/v1/"

export const dynamic = "force-dynamic";

export async function GET(req: Request) {
console.log("Success: GET /api/transaction");
Expand Down
3 changes: 1 addition & 2 deletions src/app/api/transactions/route.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
export const dynamic = "force-dynamic";
import { getPgClient } from "@/lib/db";
import { sql } from "@pgtyped/runtime";
import { IGetTransactionsCountQuery, IGetTransactionsQuery } from "./route.types";

export const dynamic = "force-dynamic";

export async function POST(req: Request) {
console.log("Success: POST /api/transactions");
try {
Expand Down
4 changes: 2 additions & 2 deletions src/app/blocks/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export const dynamic = "force-dynamic";
import { BlocksTable } from "@/components/BlocksTable";
import getBlocks from "@/components/BlocksTable/getBlocks";
import { getBlocks } from "@/components/BlocksTable/getBlocks";
import { getQueryClient } from "@/lib/utils";
import { HydrationBoundary, dehydrate } from "@tanstack/react-query";

export const dynamic = "force-dynamic";

const Page = () => {
const queryClient = getQueryClient();
Expand Down
3 changes: 1 addition & 2 deletions src/app/ibc/channels/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
export const dynamic = "force-dynamic";
import { ChannelsTable } from "@/components/ibc/channels/ChannelsTable";
import { getIbcChannels } from "@/components/ibc/channels/getIbcChannels";
import { getQueryClient } from "@/lib/utils";
import { HydrationBoundary, dehydrate } from "@tanstack/react-query";



const Page = () => {
const queryClient = getQueryClient();

Expand Down
1 change: 1 addition & 0 deletions src/app/ibc/clients/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const dynamic = "force-dynamic";
import { ClientsTable } from "@/components/ibc/clients/ClientsTable";
import { getIbcClients } from "@/components/ibc/clients/getIbcClients";
import { getQueryClient } from "@/lib/utils";
Expand Down
1 change: 1 addition & 0 deletions src/app/ibc/connections/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const dynamic = "force-dynamic";
import ConnectionsTable from "@/components/ibc/connections/ConnectionsTable";
import { getIbcConnections } from "@/components/ibc/connections/getIbcConnections";
import { getQueryClient } from "@/lib/utils";
Expand Down
2 changes: 1 addition & 1 deletion src/components/BlocksTable/getBlocks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BlocksTableQuery } from "@/lib/validators/table";

export default async function getBlocks ({ endpoint, pageIndex } : ({ endpoint: string, pageIndex: number })) {
export async function getBlocks ({ endpoint, pageIndex } : ({ endpoint: string, pageIndex: number })) {
console.log(`Fetching: POST ${endpoint}?page=${pageIndex}`);
const res = await fetch(`http://localhost:3000${endpoint}?page=${pageIndex}`, { method: "POST" });
const json = await res.json();
Expand Down
2 changes: 1 addition & 1 deletion src/components/BlocksTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useSuspenseQuery } from "@tanstack/react-query";
import { useState } from "react";
import { PaginatedDataTable } from "../ui/paginated-data-table";
import { PaginationState, getCoreRowModel, useReactTable } from "@tanstack/react-table";
import getBlocks from "./getBlocks";
import { getBlocks } from "./getBlocks";
import { cn } from "@/lib/utils";

export interface QueryOptions {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Providers/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function ThemeProvider({ children, ...props }: ThemeProviderProps) {
}

const penumbraTransport = createGrpcWebTransport({
baseUrl: process.env.PENUMBRA_GRPC_ENDPOINT ? process.env.PENUMBRA_GRPC_ENDPOINT : "http://localhost:8080",
baseUrl: process.env?.PENUMBRA_GRPC_ENDPOINT ?? "http://localhost:8080",
});


Expand Down
3 changes: 0 additions & 3 deletions src/components/ibc/channels/getIbcChannels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ export async function getIbcChannels({ endpoint, pageIndex } : { endpoint: strin
console.log(`Fetching: GET ${endpoint}?page=${pageIndex}`);
const res = await fetch(`http://localhost:3000${endpoint}?page=${pageIndex}`, { method: "GET" });
return await res.json();
// const json = await res.json();
// console.log("Fetched Result:", json);
// return json;
// const result = ChannelsTableData.safeParse(json);
// if (result.success) {
// return result.data;
Expand Down
3 changes: 2 additions & 1 deletion src/components/ibc/clients/getIbcClients.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export async function getIbcClients({ endpoint, pageIndex } : { endpoint: string, pageIndex: number }) {
console.log(`Fetching: GET ${endpoint}?page=${pageIndex}`);
const res = await fetch(`http://localhost:3000${endpoint}?page=${pageIndex}`, { method: "GET" });
return await res.json();
const json = await res.json();
return json;
}

0 comments on commit a1157d0

Please sign in to comment.