-
Notifications
You must be signed in to change notification settings - Fork 84
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
Replace Next with Vite + tanstack/router #4612
Conversation
|
📚 Storybook DeploymentThe latest changes are available as preview in: https://f71e2555.hive-storybook.pages.dev |
🐋 This PR was built and pushed to the following Docker images (tag: Docker Bake metadata{
"app": {
"buildx.build.ref": "builder-c9e33c35-67fe-4abb-98c7-dac5f2f9c64c/builder-c9e33c35-67fe-4abb-98c7-dac5f2f9c64c0/50x7p9242vij5ll2lhhv03hn1",
"containerimage.descriptor": {
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
"digest": "sha256:ed86ef30a616e9aba55f71bed30989f7ba44573c62f190d97fa0b46b9bd45846",
"size": 685
},
"containerimage.digest": "sha256:ed86ef30a616e9aba55f71bed30989f7ba44573c62f190d97fa0b46b9bd45846",
"image.name": "ghcr.io/kamilkisiela/graphql-hive/app:b0c6a62ec387c36b5dde702ad8b7382f8f052023,ghcr.io/kamilkisiela/graphql-hive/app:kamil_vite"
},
"composition-federation-2": {
"buildx.build.ref": "builder-c9e33c35-67fe-4abb-98c7-dac5f2f9c64c/builder-c9e33c35-67fe-4abb-98c7-dac5f2f9c64c0/mvkna7sjqydul6ialr2aevgdv",
"containerimage.descriptor": {
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
"digest": "sha256:109ff969ae378dc413dae2f85901d8ce1912a4f6b01bed4756a19843b9d6282b",
"size": 685
},
"containerimage.digest": "sha256:109ff969ae378dc413dae2f85901d8ce1912a4f6b01bed4756a19843b9d6282b",
"image.name": "ghcr.io/kamilkisiela/graphql-hive/composition-federation-2:b0c6a62ec387c36b5dde702ad8b7382f8f052023,ghcr.io/kamilkisiela/graphql-hive/composition-federation-2:kamil_vite"
},
"emails": {
"buildx.build.ref": "builder-c9e33c35-67fe-4abb-98c7-dac5f2f9c64c/builder-c9e33c35-67fe-4abb-98c7-dac5f2f9c64c0/mpb1chu6w7tekkuo328iwrzql",
"containerimage.descriptor": {
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
"digest": "sha256:9b2fae5a3953f96fe56e677f1c2e265258257bd49840d6490313f1a7e9407d46",
"size": 685
},
"containerimage.digest": "sha256:9b2fae5a3953f96fe56e677f1c2e265258257bd49840d6490313f1a7e9407d46",
"image.name": "ghcr.io/kamilkisiela/graphql-hive/emails:b0c6a62ec387c36b5dde702ad8b7382f8f052023,ghcr.io/kamilkisiela/graphql-hive/emails:kamil_vite"
},
"policy": {
"buildx.build.ref": "builder-c9e33c35-67fe-4abb-98c7-dac5f2f9c64c/builder-c9e33c35-67fe-4abb-98c7-dac5f2f9c64c0/zctl7m7yaoksmqhtm3o2sliru",
"containerimage.descriptor": {
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
"digest": "sha256:4ba5340caf12c5003de456cad579425908d06411135d6d88fa48d7d1b3435e74",
"size": 685
},
"containerimage.digest": "sha256:4ba5340caf12c5003de456cad579425908d06411135d6d88fa48d7d1b3435e74",
"image.name": "ghcr.io/kamilkisiela/graphql-hive/policy:b0c6a62ec387c36b5dde702ad8b7382f8f052023,ghcr.io/kamilkisiela/graphql-hive/policy:kamil_vite"
},
"rate-limit": {
"buildx.build.ref": "builder-c9e33c35-67fe-4abb-98c7-dac5f2f9c64c/builder-c9e33c35-67fe-4abb-98c7-dac5f2f9c64c0/yu0ye16xo776ui4rmryp6yiv2",
"containerimage.descriptor": {
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
"digest": "sha256:df133c96c72d22e3c2b548a4782bfc4b59bebee68410113d4b82b5592936ad8b",
"size": 685
},
"containerimage.digest": "sha256:df133c96c72d22e3c2b548a4782bfc4b59bebee68410113d4b82b5592936ad8b",
"image.name": "ghcr.io/kamilkisiela/graphql-hive/rate-limit:b0c6a62ec387c36b5dde702ad8b7382f8f052023,ghcr.io/kamilkisiela/graphql-hive/rate-limit:kamil_vite"
},
"schema": {
"buildx.build.ref": "builder-c9e33c35-67fe-4abb-98c7-dac5f2f9c64c/builder-c9e33c35-67fe-4abb-98c7-dac5f2f9c64c0/t0c1lb1ms9eoonh3uxfuve6hd",
"containerimage.descriptor": {
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
"digest": "sha256:2ac6352655835c4500553fd86e0695e35bdb166a63ee6e526064893bd7e86f06",
"size": 685
},
"containerimage.digest": "sha256:2ac6352655835c4500553fd86e0695e35bdb166a63ee6e526064893bd7e86f06",
"image.name": "ghcr.io/kamilkisiela/graphql-hive/schema:b0c6a62ec387c36b5dde702ad8b7382f8f052023,ghcr.io/kamilkisiela/graphql-hive/schema:kamil_vite"
},
"server": {
"buildx.build.ref": "builder-c9e33c35-67fe-4abb-98c7-dac5f2f9c64c/builder-c9e33c35-67fe-4abb-98c7-dac5f2f9c64c0/vxtj2ewllv4l4lei6v7snr4pq",
"containerimage.descriptor": {
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
"digest": "sha256:5f20d51b4871cc1299840ff113a289f16d66b9313a3f40b613714680d9ff712b",
"size": 685
},
"containerimage.digest": "sha256:5f20d51b4871cc1299840ff113a289f16d66b9313a3f40b613714680d9ff712b",
"image.name": "ghcr.io/kamilkisiela/graphql-hive/server:b0c6a62ec387c36b5dde702ad8b7382f8f052023,ghcr.io/kamilkisiela/graphql-hive/server:kamil_vite"
},
"storage": {
"buildx.build.ref": "builder-c9e33c35-67fe-4abb-98c7-dac5f2f9c64c/builder-c9e33c35-67fe-4abb-98c7-dac5f2f9c64c0/txyvtzc5tj61zgjv2yjme63a9",
"containerimage.descriptor": {
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
"digest": "sha256:e6ed1bc821b1aca65dea5a85504c92fdaa2757381f3ccab8a7a5bbad3225dfc9",
"size": 685
},
"containerimage.digest": "sha256:e6ed1bc821b1aca65dea5a85504c92fdaa2757381f3ccab8a7a5bbad3225dfc9",
"image.name": "ghcr.io/kamilkisiela/graphql-hive/storage:b0c6a62ec387c36b5dde702ad8b7382f8f052023,ghcr.io/kamilkisiela/graphql-hive/storage:kamil_vite"
},
"stripe-billing": {
"buildx.build.ref": "builder-c9e33c35-67fe-4abb-98c7-dac5f2f9c64c/builder-c9e33c35-67fe-4abb-98c7-dac5f2f9c64c0/azykd1aja7i7z18kxkejlbqr8",
"containerimage.descriptor": {
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
"digest": "sha256:ac51273950d379b45664c1dabd06d6bc76c45e8fcfceab7727a946e47df90d25",
"size": 685
},
"containerimage.digest": "sha256:ac51273950d379b45664c1dabd06d6bc76c45e8fcfceab7727a946e47df90d25",
"image.name": "ghcr.io/kamilkisiela/graphql-hive/stripe-billing:b0c6a62ec387c36b5dde702ad8b7382f8f052023,ghcr.io/kamilkisiela/graphql-hive/stripe-billing:kamil_vite"
},
"tokens": {
"buildx.build.ref": "builder-c9e33c35-67fe-4abb-98c7-dac5f2f9c64c/builder-c9e33c35-67fe-4abb-98c7-dac5f2f9c64c0/iel6wpk68ikl4ox5362den1ka",
"containerimage.descriptor": {
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
"digest": "sha256:4a35003563a8e1a7bca22a299a46f8df493cad8ec6e2aa08fa4e9ef53cfc9485",
"size": 685
},
"containerimage.digest": "sha256:4a35003563a8e1a7bca22a299a46f8df493cad8ec6e2aa08fa4e9ef53cfc9485",
"image.name": "ghcr.io/kamilkisiela/graphql-hive/tokens:b0c6a62ec387c36b5dde702ad8b7382f8f052023,ghcr.io/kamilkisiela/graphql-hive/tokens:kamil_vite"
},
"usage": {
"buildx.build.ref": "builder-c9e33c35-67fe-4abb-98c7-dac5f2f9c64c/builder-c9e33c35-67fe-4abb-98c7-dac5f2f9c64c0/4jlsi222vgwpot1auyqu2eq7a",
"containerimage.descriptor": {
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
"digest": "sha256:f0de9eae867bfccd48649877a7343772a1e50f6445580f434b9c4c5aa8d1d058",
"size": 685
},
"containerimage.digest": "sha256:f0de9eae867bfccd48649877a7343772a1e50f6445580f434b9c4c5aa8d1d058",
"image.name": "ghcr.io/kamilkisiela/graphql-hive/usage:b0c6a62ec387c36b5dde702ad8b7382f8f052023,ghcr.io/kamilkisiela/graphql-hive/usage:kamil_vite"
},
"usage-estimator": {
"buildx.build.ref": "builder-c9e33c35-67fe-4abb-98c7-dac5f2f9c64c/builder-c9e33c35-67fe-4abb-98c7-dac5f2f9c64c0/6yxp9qhp17mqxalbltmwcadsr",
"containerimage.descriptor": {
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
"digest": "sha256:68bf39b0ec87a2ec51db6fdc0cd7f872b6bae8f585f085af572115d8f71b1e95",
"size": 685
},
"containerimage.digest": "sha256:68bf39b0ec87a2ec51db6fdc0cd7f872b6bae8f585f085af572115d8f71b1e95",
"image.name": "ghcr.io/kamilkisiela/graphql-hive/usage-estimator:b0c6a62ec387c36b5dde702ad8b7382f8f052023,ghcr.io/kamilkisiela/graphql-hive/usage-estimator:kamil_vite"
},
"usage-ingestor": {
"buildx.build.ref": "builder-c9e33c35-67fe-4abb-98c7-dac5f2f9c64c/builder-c9e33c35-67fe-4abb-98c7-dac5f2f9c64c0/mau9bkdcc2jm8ctgrgfhu79l5",
"containerimage.descriptor": {
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
"digest": "sha256:80271e7322ec70d8fa8ec22ca455c0a86cf299b5838b0a227b3335c6e621b5cd",
"size": 685
},
"containerimage.digest": "sha256:80271e7322ec70d8fa8ec22ca455c0a86cf299b5838b0a227b3335c6e621b5cd",
"image.name": "ghcr.io/kamilkisiela/graphql-hive/usage-ingestor:b0c6a62ec387c36b5dde702ad8b7382f8f052023,ghcr.io/kamilkisiela/graphql-hive/usage-ingestor:kamil_vite"
},
"webhooks": {
"buildx.build.ref": "builder-c9e33c35-67fe-4abb-98c7-dac5f2f9c64c/builder-c9e33c35-67fe-4abb-98c7-dac5f2f9c64c0/focx954nustfb1zeua4k5jm18",
"containerimage.descriptor": {
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
"digest": "sha256:94db34157fb5a608ed305e234ccad045d2e1bb6400d8b27ecc7ac938c811838c",
"size": 685
},
"containerimage.digest": "sha256:94db34157fb5a608ed305e234ccad045d2e1bb6400d8b27ecc7ac938c811838c",
"image.name": "ghcr.io/kamilkisiela/graphql-hive/webhooks:b0c6a62ec387c36b5dde702ad8b7382f8f052023,ghcr.io/kamilkisiela/graphql-hive/webhooks:kamil_vite"
}
} |
@@ -1,24 +0,0 @@ | |||
FROM node:21.7.3-slim |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can also consider using a simple HTTP server to serve the artifact, right?
something like busybox
(https://lipanski.com/posts/smallest-docker-image-static-website)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true but we have routes there as well, we need an http server
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could move them to graphql-api
and serve from there, but I did not want to do it in this PR
96d59bc
to
c3bf244
Compare
8f9f5e3
to
e4c2afd
Compare
}, | ||
}); | ||
void (await replace('/')); | ||
void router.navigate({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we need to handle users who have more than one organization?
if (props.organizations.length > 1) {
const notCurrentOrg = props.organizations.find((org: any) => org.cleanId !== props.organizationId);
router.navigate({
to: `/${notCurrentOrg.cleanId}`,
});
} else {
router.navigate({
to: '/org/new',
});
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm it's redirecting to /
.
When you enter /
, it will find an organization you visited previously or redirect you to one of them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left one comment about router and how to handle delete organization when user have more then 1 organizations
💻 Website PreviewThe latest changes are available as preview in: https://dfa37297.hive-landing-page.pages.dev |
Build
pnpm deploy
is no longer neededvite
builds static files,runify
builds a server code to serve static files and handle api routes.turbo
can now cachepnpm build
of@hive/app
Development
pnpm dev
gives us hot reloading and in general similar experience to what we had with Nextfastify
as it has a good integration withvite
(@fastify/vite
, there wasvite-express
but we already usefastify
in Hive, so it was an obvious choice). The@fastify/vite
is only used in development node.Production
vite build
are served by@fastify/static
fastify
Docker
From now on, we serve
@hive/app
in the same fashion as other services, no dedicated docker file or configuration. The size of a docker image is now 4x lower than the previous one.Routing
We moved from file-based to code-base routing and all routes are in
router.tsx
file. I hope you like it :)All pages are in
src/page
directory, stored as flat files. To be honest, we could have a hierarchy there driven by directory structure, but I prefer flat files as it's easier to navigate and we avoid doing../../../../
shit.Thanks to
@tanstack/router
, all pieces of routing are type-safe, even params, you will love it.I also removed
useRouteSelector
hook that gave us{organization|project|target}Id
props based on an URL. We simply pass these using props.Runtime Environment Variables
To still be able to build the app, ship it as a Docker image and pass env vars when running the docker container, we handle
GET /__env.js
infastify
, instead of generating a file.