Skip to content
Merged
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
83 changes: 31 additions & 52 deletions apps/dashboard/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { Route as ProtectedOwnerRepoIndexRouteImport } from './routes/_protected
import { Route as ApiGithubAppCallbackRouteImport } from './routes/api/github/app/callback'
import { Route as ApiGithubAppAuthorizeRouteImport } from './routes/api/github/app/authorize'
import { Route as ProtectedOwnerRepoPullsRouteImport } from './routes/_protected/$owner/$repo/pulls'
import { Route as ProtectedOwnerRepoIssuesRouteImport } from './routes/_protected/$owner/$repo/issues'
import { Route as ProtectedOwnerRepoIssuesIndexRouteImport } from './routes/_protected/$owner/$repo/issues.index'
import { Route as ProtectedOwnerRepoReviewPullIdRouteImport } from './routes/_protected/$owner/$repo/review.$pullId'
import { Route as ProtectedOwnerRepoPullPullIdRouteImport } from './routes/_protected/$owner/$repo/pull.$pullId'
import { Route as ProtectedOwnerRepoIssuesNewRouteImport } from './routes/_protected/$owner/$repo/issues.new'
Expand Down Expand Up @@ -135,10 +135,10 @@ const ProtectedOwnerRepoPullsRoute = ProtectedOwnerRepoPullsRouteImport.update({
path: '/$owner/$repo/pulls',
getParentRoute: () => ProtectedRoute,
} as any)
const ProtectedOwnerRepoIssuesRoute =
ProtectedOwnerRepoIssuesRouteImport.update({
id: '/$owner/$repo/issues',
path: '/$owner/$repo/issues',
const ProtectedOwnerRepoIssuesIndexRoute =
ProtectedOwnerRepoIssuesIndexRouteImport.update({
id: '/$owner/$repo/issues/',
path: '/$owner/$repo/issues/',
getParentRoute: () => ProtectedRoute,
} as any)
const ProtectedOwnerRepoReviewPullIdRoute =
Expand All @@ -155,15 +155,15 @@ const ProtectedOwnerRepoPullPullIdRoute =
} as any)
const ProtectedOwnerRepoIssuesNewRoute =
ProtectedOwnerRepoIssuesNewRouteImport.update({
id: '/new',
path: '/new',
getParentRoute: () => ProtectedOwnerRepoIssuesRoute,
id: '/$owner/$repo/issues/new',
path: '/$owner/$repo/issues/new',
getParentRoute: () => ProtectedRoute,
} as any)
const ProtectedOwnerRepoIssuesIssueIdRoute =
ProtectedOwnerRepoIssuesIssueIdRouteImport.update({
id: '/$issueId',
path: '/$issueId',
getParentRoute: () => ProtectedOwnerRepoIssuesRoute,
id: '/$owner/$repo/issues/$issueId',
path: '/$owner/$repo/issues/$issueId',
getParentRoute: () => ProtectedRoute,
} as any)

export interface FileRoutesByFullPath {
Expand All @@ -182,7 +182,6 @@ export interface FileRoutesByFullPath {
'/api/webhooks/github': typeof ApiWebhooksGithubRoute
'/$owner/': typeof ProtectedOwnerIndexRoute
'/settings/': typeof ProtectedSettingsIndexRoute
'/$owner/$repo/issues': typeof ProtectedOwnerRepoIssuesRouteWithChildren
'/$owner/$repo/pulls': typeof ProtectedOwnerRepoPullsRoute
'/api/github/app/authorize': typeof ApiGithubAppAuthorizeRoute
'/api/github/app/callback': typeof ApiGithubAppCallbackRoute
Expand All @@ -191,6 +190,7 @@ export interface FileRoutesByFullPath {
'/$owner/$repo/issues/new': typeof ProtectedOwnerRepoIssuesNewRoute
'/$owner/$repo/pull/$pullId': typeof ProtectedOwnerRepoPullPullIdRoute
'/$owner/$repo/review/$pullId': typeof ProtectedOwnerRepoReviewPullIdRoute
'/$owner/$repo/issues/': typeof ProtectedOwnerRepoIssuesIndexRoute
}
export interface FileRoutesByTo {
'/$': typeof SplatRoute
Expand All @@ -207,7 +207,6 @@ export interface FileRoutesByTo {
'/api/webhooks/github': typeof ApiWebhooksGithubRoute
'/$owner': typeof ProtectedOwnerIndexRoute
'/settings': typeof ProtectedSettingsIndexRoute
'/$owner/$repo/issues': typeof ProtectedOwnerRepoIssuesRouteWithChildren
'/$owner/$repo/pulls': typeof ProtectedOwnerRepoPullsRoute
'/api/github/app/authorize': typeof ApiGithubAppAuthorizeRoute
'/api/github/app/callback': typeof ApiGithubAppCallbackRoute
Expand All @@ -216,6 +215,7 @@ export interface FileRoutesByTo {
'/$owner/$repo/issues/new': typeof ProtectedOwnerRepoIssuesNewRoute
'/$owner/$repo/pull/$pullId': typeof ProtectedOwnerRepoPullPullIdRoute
'/$owner/$repo/review/$pullId': typeof ProtectedOwnerRepoReviewPullIdRoute
'/$owner/$repo/issues': typeof ProtectedOwnerRepoIssuesIndexRoute
}
export interface FileRoutesById {
__root__: typeof rootRouteImport
Expand All @@ -235,7 +235,6 @@ export interface FileRoutesById {
'/api/webhooks/github': typeof ApiWebhooksGithubRoute
'/_protected/$owner/': typeof ProtectedOwnerIndexRoute
'/_protected/settings/': typeof ProtectedSettingsIndexRoute
'/_protected/$owner/$repo/issues': typeof ProtectedOwnerRepoIssuesRouteWithChildren
'/_protected/$owner/$repo/pulls': typeof ProtectedOwnerRepoPullsRoute
'/api/github/app/authorize': typeof ApiGithubAppAuthorizeRoute
'/api/github/app/callback': typeof ApiGithubAppCallbackRoute
Expand All @@ -244,6 +243,7 @@ export interface FileRoutesById {
'/_protected/$owner/$repo/issues/new': typeof ProtectedOwnerRepoIssuesNewRoute
'/_protected/$owner/$repo/pull/$pullId': typeof ProtectedOwnerRepoPullPullIdRoute
'/_protected/$owner/$repo/review/$pullId': typeof ProtectedOwnerRepoReviewPullIdRoute
'/_protected/$owner/$repo/issues/': typeof ProtectedOwnerRepoIssuesIndexRoute
}
export interface FileRouteTypes {
fileRoutesByFullPath: FileRoutesByFullPath
Expand All @@ -263,7 +263,6 @@ export interface FileRouteTypes {
| '/api/webhooks/github'
| '/$owner/'
| '/settings/'
| '/$owner/$repo/issues'
| '/$owner/$repo/pulls'
| '/api/github/app/authorize'
| '/api/github/app/callback'
Expand All @@ -272,6 +271,7 @@ export interface FileRouteTypes {
| '/$owner/$repo/issues/new'
| '/$owner/$repo/pull/$pullId'
| '/$owner/$repo/review/$pullId'
| '/$owner/$repo/issues/'
fileRoutesByTo: FileRoutesByTo
to:
| '/$'
Expand All @@ -288,7 +288,6 @@ export interface FileRouteTypes {
| '/api/webhooks/github'
| '/$owner'
| '/settings'
| '/$owner/$repo/issues'
| '/$owner/$repo/pulls'
| '/api/github/app/authorize'
| '/api/github/app/callback'
Expand All @@ -297,6 +296,7 @@ export interface FileRouteTypes {
| '/$owner/$repo/issues/new'
| '/$owner/$repo/pull/$pullId'
| '/$owner/$repo/review/$pullId'
| '/$owner/$repo/issues'
id:
| '__root__'
| '/$'
Expand All @@ -315,7 +315,6 @@ export interface FileRouteTypes {
| '/api/webhooks/github'
| '/_protected/$owner/'
| '/_protected/settings/'
| '/_protected/$owner/$repo/issues'
| '/_protected/$owner/$repo/pulls'
| '/api/github/app/authorize'
| '/api/github/app/callback'
Expand All @@ -324,6 +323,7 @@ export interface FileRouteTypes {
| '/_protected/$owner/$repo/issues/new'
| '/_protected/$owner/$repo/pull/$pullId'
| '/_protected/$owner/$repo/review/$pullId'
| '/_protected/$owner/$repo/issues/'
fileRoutesById: FileRoutesById
}
export interface RootRouteChildren {
Expand Down Expand Up @@ -481,11 +481,11 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof ProtectedOwnerRepoPullsRouteImport
parentRoute: typeof ProtectedRoute
}
'/_protected/$owner/$repo/issues': {
id: '/_protected/$owner/$repo/issues'
'/_protected/$owner/$repo/issues/': {
id: '/_protected/$owner/$repo/issues/'
path: '/$owner/$repo/issues'
fullPath: '/$owner/$repo/issues'
preLoaderRoute: typeof ProtectedOwnerRepoIssuesRouteImport
fullPath: '/$owner/$repo/issues/'
preLoaderRoute: typeof ProtectedOwnerRepoIssuesIndexRouteImport
parentRoute: typeof ProtectedRoute
}
'/_protected/$owner/$repo/review/$pullId': {
Expand All @@ -504,17 +504,17 @@ declare module '@tanstack/react-router' {
}
'/_protected/$owner/$repo/issues/new': {
id: '/_protected/$owner/$repo/issues/new'
path: '/new'
path: '/$owner/$repo/issues/new'
fullPath: '/$owner/$repo/issues/new'
preLoaderRoute: typeof ProtectedOwnerRepoIssuesNewRouteImport
parentRoute: typeof ProtectedOwnerRepoIssuesRoute
parentRoute: typeof ProtectedRoute
}
'/_protected/$owner/$repo/issues/$issueId': {
id: '/_protected/$owner/$repo/issues/$issueId'
path: '/$issueId'
path: '/$owner/$repo/issues/$issueId'
fullPath: '/$owner/$repo/issues/$issueId'
preLoaderRoute: typeof ProtectedOwnerRepoIssuesIssueIdRouteImport
parentRoute: typeof ProtectedOwnerRepoIssuesRoute
parentRoute: typeof ProtectedRoute
}
}
}
Expand All @@ -532,34 +532,20 @@ const ProtectedSettingsRouteChildren: ProtectedSettingsRouteChildren = {
const ProtectedSettingsRouteWithChildren =
ProtectedSettingsRoute._addFileChildren(ProtectedSettingsRouteChildren)

interface ProtectedOwnerRepoIssuesRouteChildren {
ProtectedOwnerRepoIssuesIssueIdRoute: typeof ProtectedOwnerRepoIssuesIssueIdRoute
ProtectedOwnerRepoIssuesNewRoute: typeof ProtectedOwnerRepoIssuesNewRoute
}

const ProtectedOwnerRepoIssuesRouteChildren: ProtectedOwnerRepoIssuesRouteChildren =
{
ProtectedOwnerRepoIssuesIssueIdRoute: ProtectedOwnerRepoIssuesIssueIdRoute,
ProtectedOwnerRepoIssuesNewRoute: ProtectedOwnerRepoIssuesNewRoute,
}

const ProtectedOwnerRepoIssuesRouteWithChildren =
ProtectedOwnerRepoIssuesRoute._addFileChildren(
ProtectedOwnerRepoIssuesRouteChildren,
)

interface ProtectedRouteChildren {
ProtectedIssuesRoute: typeof ProtectedIssuesRoute
ProtectedPullsRoute: typeof ProtectedPullsRoute
ProtectedReviewsRoute: typeof ProtectedReviewsRoute
ProtectedSettingsRoute: typeof ProtectedSettingsRouteWithChildren
ProtectedIndexRoute: typeof ProtectedIndexRoute
ProtectedOwnerIndexRoute: typeof ProtectedOwnerIndexRoute
ProtectedOwnerRepoIssuesRoute: typeof ProtectedOwnerRepoIssuesRouteWithChildren
ProtectedOwnerRepoPullsRoute: typeof ProtectedOwnerRepoPullsRoute
ProtectedOwnerRepoIndexRoute: typeof ProtectedOwnerRepoIndexRoute
ProtectedOwnerRepoIssuesIssueIdRoute: typeof ProtectedOwnerRepoIssuesIssueIdRoute
ProtectedOwnerRepoIssuesNewRoute: typeof ProtectedOwnerRepoIssuesNewRoute
ProtectedOwnerRepoPullPullIdRoute: typeof ProtectedOwnerRepoPullPullIdRoute
ProtectedOwnerRepoReviewPullIdRoute: typeof ProtectedOwnerRepoReviewPullIdRoute
ProtectedOwnerRepoIssuesIndexRoute: typeof ProtectedOwnerRepoIssuesIndexRoute
}

const ProtectedRouteChildren: ProtectedRouteChildren = {
Expand All @@ -569,11 +555,13 @@ const ProtectedRouteChildren: ProtectedRouteChildren = {
ProtectedSettingsRoute: ProtectedSettingsRouteWithChildren,
ProtectedIndexRoute: ProtectedIndexRoute,
ProtectedOwnerIndexRoute: ProtectedOwnerIndexRoute,
ProtectedOwnerRepoIssuesRoute: ProtectedOwnerRepoIssuesRouteWithChildren,
ProtectedOwnerRepoPullsRoute: ProtectedOwnerRepoPullsRoute,
ProtectedOwnerRepoIndexRoute: ProtectedOwnerRepoIndexRoute,
ProtectedOwnerRepoIssuesIssueIdRoute: ProtectedOwnerRepoIssuesIssueIdRoute,
ProtectedOwnerRepoIssuesNewRoute: ProtectedOwnerRepoIssuesNewRoute,
ProtectedOwnerRepoPullPullIdRoute: ProtectedOwnerRepoPullPullIdRoute,
ProtectedOwnerRepoReviewPullIdRoute: ProtectedOwnerRepoReviewPullIdRoute,
ProtectedOwnerRepoIssuesIndexRoute: ProtectedOwnerRepoIssuesIndexRoute,
}

const ProtectedRouteWithChildren = ProtectedRoute._addFileChildren(
Expand All @@ -595,12 +583,3 @@ const rootRouteChildren: RootRouteChildren = {
export const routeTree = rootRouteImport
._addFileChildren(rootRouteChildren)
._addFileTypes<FileRouteTypes>()

import type { getRouter } from './router.tsx'
import type { createStart } from '@tanstack/react-start'
declare module '@tanstack/react-start' {
interface Register {
ssr: true
router: Awaited<ReturnType<typeof getRouter>>
}
}
2 changes: 2 additions & 0 deletions apps/dashboard/src/router.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createRouter as createTanStackRouter } from "@tanstack/react-router";
import { setupRouterSsrQueryIntegration } from "@tanstack/react-router-ssr-query";
import { DashboardContentLoading } from "#/components/layouts/dashboard-content-loading";
import { DashboardErrorScreen } from "#/components/layouts/dashboard-error-screen";
import { NotFoundScreen } from "#/components/layouts/not-found-screen";
import {
Expand All @@ -19,6 +20,7 @@ export function getRouter() {
defaultPreload: "intent",
defaultPreloadStaleTime: 0,
defaultPendingMs: 0,
defaultPendingComponent: DashboardContentLoading,
defaultErrorComponent: DashboardErrorScreen,
defaultNotFoundComponent: NotFoundScreen,
Wrap: ({ children }) => (
Expand Down
19 changes: 16 additions & 3 deletions apps/dashboard/src/routes/_protected.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,35 @@ import { getSession } from "#/lib/auth.functions";
import { checkSetupComplete } from "#/lib/github.functions";
import { buildSeo, formatPageTitle, PRIVATE_ROUTE_HEADERS } from "#/lib/seo";

/**
* Cache the auth check so navigations within the dashboard are instant.
* The cache is cleared on full page reloads. If the session expires mid-use,
* API calls in child routes will 401 and the error boundary handles it.
*/
let cachedAuth: Awaited<ReturnType<typeof getSession>> | null = null;

export const Route = createFileRoute("/_protected")({
beforeLoad: async ({ location }) => {
const session = await getSession();
if (cachedAuth) return cachedAuth;

const [session, setupComplete] = await Promise.all([
getSession(),
checkSetupComplete(),
]);

if (!session) {
throw redirect({
to: "/login",
search: { redirect: location.href },
});
}

const setupComplete = await checkSetupComplete();
if (!setupComplete) {
throw redirect({ to: "/setup" });
}

return { user: session.user, session: session.session };
cachedAuth = { user: session.user, session: session.session };
return cachedAuth;
},
headers: () => PRIVATE_ROUTE_HEADERS,
head: ({ match }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { useHasMounted } from "#/lib/use-has-mounted";

const PER_PAGE = 30;

export const Route = createFileRoute("/_protected/$owner/$repo/issues")({
export const Route = createFileRoute("/_protected/$owner/$repo/issues/")({
ssr: false,
head: ({ match, params }) =>
buildSeo({
Expand Down
Loading