Skip to content

Commit

Permalink
restore tbConsumer start query; add dummy page to test tb dummy query
Browse files Browse the repository at this point in the history
  • Loading branch information
matyson committed May 21, 2024
1 parent 15ec77b commit 4993831
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
15 changes: 15 additions & 0 deletions apps/deepsirius-ui/src/pages/hello.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { api } from '~/utils/api';

export default function Page() {
const { data, isLoading } = api.tbConsumer.hello.useQuery();

if (isLoading) {
return <div>Loading...</div>;
}

return (
<div className="flex p-4">
<pre>{JSON.stringify(data, null, 2)}</pre>
</div>
);
}
27 changes: 18 additions & 9 deletions apps/deepsirius-ui/src/server/api/routers/tb_consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,14 @@ export const tbConsumerRouter = createTRPCRouter({
)
.query(async ({ input }) => {
const url = `${env.TENSORBOARD_API_URL}/api/tensorboard/start`;

const headers = new Headers();
headers.append('Content-Type', 'application/json');
headers.append('x-api-key', env.TENSORBOARD_API_KEY);
const options = {
const res = await fetch(url, {
method: 'POST',
headers,
headers: {
'Content-Type': 'application/json',
'x-api-key': env.TENSORBOARD_API_KEY,
},
body: JSON.stringify(input),
};

const res = await fetch(url, { ...options, cache: 'no-store' });
});

const data: unknown = await res.json();

Expand All @@ -51,4 +48,16 @@ export const tbConsumerRouter = createTRPCRouter({

return parsed;
}),
hello: protectedProcedure.query(async () => {
const url = `${env.TENSORBOARD_API_URL}/api/`;
const res = await fetch(url, {
method: 'GET',
headers: {
'x-api-key': env.TENSORBOARD_API_KEY,
},
});

const data: unknown = await res.json();
return data;
}),
});

0 comments on commit 4993831

Please sign in to comment.