Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: call bootstrap before running the app #398

Open
wants to merge 1 commit into
base: 11-20-refactor_call_bootstrap_before_running_the_app_w_o_sdk_update_
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions apps/hub/src/domains/auth/queries/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ export const bootstrapQueryOptions = () => {
export const bootstrapOpenGbQueryOptions = () => {
return queryOptions({
...bootstrapQueryOptions(),
select: (data) =>
data.domains?.opengb || data.domains?.main || window.location.host,
select: (data) => data.domains?.opengb || window.location.host,
});
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { dataCentersQueryOptions } from "@/domains/project/queries";
import { regionsQueryOptions } from "@/domains/project/queries";
import {
Flex,
Select,
Expand All @@ -22,7 +22,7 @@ export function ServerDatacenterSelect({
...props
}: ServerDatacenterSelectProps) {
const { data } = useSuspenseQuery(
dataCentersQueryOptions({ projectId, environmentId }),
regionsQueryOptions({ projectId, environmentId }),
);

return (
Expand All @@ -38,7 +38,7 @@ export function ServerDatacenterSelect({
showLabel
projectId={projectId}
environmentId={environmentId}
datacenterId={datacenter.id}
regionId={datacenter.id}
/>
</Flex>
</SelectItem>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import { AssetImage, Flex, WithTooltip } from "@rivet-gg/components";
import { useSuspenseQuery } from "@tanstack/react-query";
import { dataCenterQueryOptions } from "../../queries";
import { regionQueryOptions } from "../../queries";
import {
REGION_LABEL,
getRegionEmoji,
getRegionKey,
} from "../matchmaker/lobby-region";

interface ServerDatacenterProps {
datacenterId: string;
regionId: string;
projectId: string;
environmentId: string;
showLabel?: boolean | "abbreviated";
}

export function ServerDatacenter({
projectId,
datacenterId,
regionId,
environmentId,
showLabel,
}: ServerDatacenterProps) {
const { data: region } = useSuspenseQuery(
dataCenterQueryOptions({ projectId, environmentId, datacenterId }),
regionQueryOptions({ projectId, environmentId, regionId }),
);

const regionKey = getRegionKey(region?.slug);
const regionKey = getRegionKey(region?.name);

if (showLabel) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function ServerRow({
showLabel="abbreviated"
projectId={projectId}
environmentId={environmentId}
datacenterId={server.datacenter}
regionId={server.datacenter}
/>
</SmallText>
<SmallText>{server.id.split("-")[0]}</SmallText>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export function ServersServerDetails({
showLabel="abbreviated"
projectId={projectId}
environmentId={environmentId}
datacenterId={data.datacenter}
regionId={data.datacenter}
/>
</SmallText>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export const serverLogsQueryOptions = (
meta,
queryKey: [_, projectId, __, environmentId, ___, serverId, ____, stream],
}) =>
rivetClient.servers.logs.getServerLogs(
rivetClient.servers.logs.get(
projectId,
environmentId,
serverId,
Expand Down Expand Up @@ -159,7 +159,7 @@ export const projectBuildsQueryOptions = ({
],
signal: abortSignal,
}) =>
rivetClient.servers.builds.listBuilds(projectId, environmentId, tags, {
rivetClient.servers.builds.list(projectId, environmentId, tags, {
abortSignal,
}),
select: (data) => data.builds,
Expand Down Expand Up @@ -188,7 +188,7 @@ export const buildQueryOptions = ({
signal: abortSignal,
queryKey: [_, projectId, __, environmentId, ___, buildId],
}) =>
rivetClient.servers.builds.getBuild(
rivetClient.servers.builds.get(
projectId,
environmentId,
buildId,
Expand All @@ -202,47 +202,43 @@ export const buildQueryOptions = ({
});
};

export const dataCentersQueryOptions = ({
export const regionsQueryOptions = ({
projectId,
environmentId,
}: { projectId: string; environmentId: string }) => {
return queryOptions({
queryKey: [
"project",
projectId,
"environment",
environmentId,
"datacenters",
],
queryKey: ["project", projectId, "environment", environmentId, "regions"],
queryFn: ({
signal: abortSignal,
queryKey: [_, projectId, __, environmentId],
}) =>
rivetClient.servers.datacenters.listDatacenters(
projectId,
environmentId,
rivetClient.actor.regions.list(
{
project: projectId,
environment: environmentId,
},
{
abortSignal,
},
),
select: (data) => data.datacenters,
select: (data) => data.regions,
});
};

export const dataCenterQueryOptions = ({
export const regionQueryOptions = ({
projectId,
environmentId,
datacenterId,
regionId,
}: {
projectId: string;
environmentId: string;
datacenterId: string;
regionId: string;
}) => {
return queryOptions({
...dataCentersQueryOptions({ projectId, environmentId }),
...regionsQueryOptions({ projectId, environmentId }),
select: (data) =>
dataCentersQueryOptions({ projectId, environmentId })
regionsQueryOptions({ projectId, environmentId })
.select?.(data)
.find((datacenter) => datacenter.id === datacenterId),
.find((region) => region.id === regionId),
});
};
3 changes: 1 addition & 2 deletions apps/hub/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ initThirdPartyProviders();
rivetClient.cloud
.bootstrap()
.then((response) => {
// @ts-ignore
run({ cacheKey: response.deploy_hash });
run({ cacheKey: response.deployHash });
})
.catch(() => {
run();
Expand Down
6 changes: 0 additions & 6 deletions apps/hub/src/routes/_authenticated/access-token.$token.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as Layout from "@/layouts/page-centered";
import { rivetClient } from "@/queries/global";
import {
Button,
Card,
Expand Down Expand Up @@ -35,9 +34,4 @@ function InviteCodeInviteRoute() {

export const Route = createFileRoute("/_authenticated/access-token/$token")({
component: InviteCodeInviteRoute,
loader: async ({ params: { token } }) => {
await rivetClient.auth.identity.accessToken.completeAccessTokenVerification(
{ accessToken: token },
);
},
});
Binary file modified apps/hub/vendor/rivet-gg-api.tgz
Binary file not shown.
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4381,14 +4381,14 @@ __metadata:

"@rivet-gg/api@file:vendor/rivet-gg-api.tgz::locator=%40rivet-gg%2Fhub%40workspace%3Aapps%2Fhub":
version: 24.1.0
resolution: "@rivet-gg/api@file:vendor/rivet-gg-api.tgz#vendor/rivet-gg-api.tgz::hash=f84e6f&locator=%40rivet-gg%2Fhub%40workspace%3Aapps%2Fhub"
resolution: "@rivet-gg/api@file:vendor/rivet-gg-api.tgz#vendor/rivet-gg-api.tgz::hash=d68df2&locator=%40rivet-gg%2Fhub%40workspace%3Aapps%2Fhub"
dependencies:
form-data: "npm:^4.0.0"
js-base64: "npm:^3.7.5"
node-fetch: "npm:2"
qs: "npm:^6.11.2"
url-join: "npm:^5.0.0"
checksum: 10c0/b13044402f475548f8dba4e0e8eeceb31056ba89137608c35a9d02ff202f323f6e6246e16779c9a380c3876b21a70435ee9d91710246bfe972ef527e2891e648
checksum: 10c0/13e5b7e2e4211b9cfe3fc07d66385bd33bc97e43c19d6fa636ef9d76dbd365d716ae15c93d6a0011519f3bb8771c9d402d4950774d77229350a111a8c5cd02ca
languageName: node
linkType: hard

Expand Down