Skip to content

Commit

Permalink
fix stringify config, move it to api
Browse files Browse the repository at this point in the history
  • Loading branch information
pankaj-peerdb committed Dec 18, 2023
1 parent 101305a commit 07cf5bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
11 changes: 10 additions & 1 deletion ui/app/api/mirrors/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ import prisma from '@/app/utils/prisma';

export const dynamic = 'force-dynamic';

const stringifyConfig = (flowArray: any[]) => {
flowArray.forEach((flow) => {
if (flow.config_proto) {
flow.config_proto = new TextDecoder().decode(flow.config_proto);
}
});
return flowArray;
};

export async function GET(request: Request) {
const mirrors = await prisma.flows.findMany({
distinct: 'name',
Expand All @@ -20,5 +29,5 @@ export async function GET(request: Request) {
};
return newMirror;
});
return new Response(JSON.stringify(flows));
return new Response(JSON.stringify(stringifyConfig(flows)));
}
13 changes: 0 additions & 13 deletions ui/app/mirrors/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ import { CDCFlows, QRepFlows } from './tables';
export const dynamic = 'force-dynamic';

const fetcher = (...args: [any]) => fetch(...args).then((res) => res.json());
const stringifyConfig = (flowArray: any[]) => {
flowArray.forEach((flow) => {
if (flow.config_proto) {
flow.config_proto = new TextDecoder().decode(flow.config_proto);
}
});
};

export default function Mirrors() {
const {
Expand Down Expand Up @@ -53,12 +46,6 @@ export default function Mirrors() {
return false;
});

if (!isLoading) {
stringifyConfig(cdcFlows);
stringifyConfig(qrepFlows);
stringifyConfig(xminFlows);
}

return (
<LayoutMain alignSelf='flex-start' justifySelf='flex-start' width='full'>
<Panel>
Expand Down

0 comments on commit 07cf5bb

Please sign in to comment.