From 6cf343d623ca8a0e2177c6979a89fa19dd5ac34a Mon Sep 17 00:00:00 2001 From: Aarnav Tale Date: Sun, 8 Dec 2024 13:52:02 -0500 Subject: [PATCH] feat: refactor all dashboard routes --- app/routes.ts | 26 ++++++++----------- .../components}/cm.client.tsx | 0 .../components}/error.tsx | 0 .../components}/fallback.tsx | 0 .../components}/unavailable.tsx | 0 .../route.tsx => acls/editor.tsx} | 7 +++-- .../components}/dns.tsx | 2 +- .../components}/domains.tsx | 2 +- .../components}/magic.tsx | 1 - .../components}/nameservers.tsx | 2 +- .../components}/rename.tsx | 3 --- .../{_data.dns._index => dns}/dialogs/dns.tsx | 0 .../dialogs/nameserver.tsx | 0 .../route.tsx => dns/overview.tsx} | 12 ++++----- .../action.tsx | 0 .../components}/machine.tsx | 0 .../components}/menu.tsx | 12 ++++----- .../dialogs/delete.tsx | 0 .../dialogs/expire.tsx | 0 .../dialogs/move.tsx | 0 .../dialogs/new.tsx | 0 .../dialogs/rename.tsx | 0 .../dialogs/routes.tsx | 0 .../dialogs/tags.tsx | 0 .../route.tsx => machines/machine.tsx} | 7 +++-- .../route.tsx => machines/overview.tsx} | 3 +-- .../route.tsx => settings/auth-keys.tsx} | 2 +- .../components}/key.tsx | 2 +- .../dialogs/expire.tsx | 0 .../dialogs/new.tsx | 0 .../route.tsx => settings/overview.tsx} | 0 .../components}/auth.tsx | 2 +- .../components}/oidc.tsx | 2 +- .../dialogs}/add.tsx | 0 .../dialogs}/remove.tsx | 0 .../dialogs}/rename.tsx | 0 .../route.tsx => users/overview.tsx} | 9 +++---- app/routes/{healthz.tsx => util/healthz.ts} | 18 +++++-------- app/routes/{_index.tsx => util/redirect.ts} | 2 +- 39 files changed, 48 insertions(+), 66 deletions(-) rename app/routes/{_data.acls._index => acls/components}/cm.client.tsx (100%) rename app/routes/{_data.acls._index => acls/components}/error.tsx (100%) rename app/routes/{_data.acls._index => acls/components}/fallback.tsx (100%) rename app/routes/{_data.acls._index => acls/components}/unavailable.tsx (100%) rename app/routes/{_data.acls._index/route.tsx => acls/editor.tsx} (98%) rename app/routes/{_data.dns._index => dns/components}/dns.tsx (98%) rename app/routes/{_data.dns._index => dns/components}/domains.tsx (98%) rename app/routes/{_data.dns._index => dns/components}/magic.tsx (96%) rename app/routes/{_data.dns._index => dns/components}/nameservers.tsx (98%) rename app/routes/{_data.dns._index => dns/components}/rename.tsx (93%) rename app/routes/{_data.dns._index => dns}/dialogs/dns.tsx (100%) rename app/routes/{_data.dns._index => dns}/dialogs/nameserver.tsx (100%) rename app/routes/{_data.dns._index/route.tsx => dns/overview.tsx} (91%) rename app/routes/{_data.machines._index => machines}/action.tsx (100%) rename app/routes/{_data.machines._index => machines/components}/machine.tsx (100%) rename app/routes/{_data.machines._index => machines/components}/menu.tsx (91%) rename app/routes/{_data.machines._index => machines}/dialogs/delete.tsx (100%) rename app/routes/{_data.machines._index => machines}/dialogs/expire.tsx (100%) rename app/routes/{_data.machines._index => machines}/dialogs/move.tsx (100%) rename app/routes/{_data.machines._index => machines}/dialogs/new.tsx (100%) rename app/routes/{_data.machines._index => machines}/dialogs/rename.tsx (100%) rename app/routes/{_data.machines._index => machines}/dialogs/routes.tsx (100%) rename app/routes/{_data.machines._index => machines}/dialogs/tags.tsx (100%) rename app/routes/{_data.machines.$id/route.tsx => machines/machine.tsx} (97%) rename app/routes/{_data.machines._index/route.tsx => machines/overview.tsx} (97%) rename app/routes/{_data.settings.auth-keys._index/route.tsx => settings/auth-keys.tsx} (99%) rename app/routes/{_data.settings.auth-keys._index => settings/components}/key.tsx (97%) rename app/routes/{_data.settings.auth-keys._index => settings}/dialogs/expire.tsx (100%) rename app/routes/{_data.settings.auth-keys._index => settings}/dialogs/new.tsx (100%) rename app/routes/{_data.settings._index/route.tsx => settings/overview.tsx} (100%) rename app/routes/{_data.users._index => users/components}/auth.tsx (97%) rename app/routes/{_data.users._index => users/components}/oidc.tsx (98%) rename app/routes/{_data.users._index => users/dialogs}/add.tsx (100%) rename app/routes/{_data.users._index => users/dialogs}/remove.tsx (100%) rename app/routes/{_data.users._index => users/dialogs}/rename.tsx (100%) rename app/routes/{_data.users._index/route.tsx => users/overview.tsx} (97%) rename app/routes/{healthz.tsx => util/healthz.ts} (63%) rename app/routes/{_index.tsx => util/redirect.ts} (69%) diff --git a/app/routes.ts b/app/routes.ts index 98aa317..74d9e09 100644 --- a/app/routes.ts +++ b/app/routes.ts @@ -3,8 +3,8 @@ import { index, layout, prefix, route } from '@remix-run/route-config' export default [ // Utility Routes - index('routes/_index.tsx'), - route('/healthz', 'routes/healthz.tsx'), + index('routes/util/redirect.ts'), + route('/healthz', 'routes/util/healthz.ts'), // Authentication Routes route('/login', 'routes/auth/login.tsx'), @@ -14,21 +14,17 @@ export default [ // All the main logged-in dashboard routes layout('layouts/dashboard.tsx', [ ...prefix('/machines', [ - index('routes/_data.machines._index/route.tsx'), - route('/:id', 'routes/_data.machines.$id/route.tsx'), - ]), - ...prefix('/users', [ - index('routes/_data.users._index/route.tsx'), - ]), - ...prefix('/dns', [ - index('routes/_data.dns._index/route.tsx'), - ]), - ...prefix('/acls', [ - index('routes/_data.acls._index/route.tsx'), + index('routes/machines/overview.tsx'), + route('/:id', 'routes/machines/machine.tsx'), ]), + + route('/users', 'routes/users/overview.tsx'), + route('/acls', 'routes/acls/editor.tsx'), + route('/dns', 'routes/dns/overview.tsx'), + ...prefix('/settings', [ - index('routes/_data.settings._index/route.tsx'), - route('/auth-keys', 'routes/_data.settings.auth-keys._index/route.tsx'), + index('routes/settings/overview.tsx'), + route('/auth-keys', 'routes/settings/auth-keys.tsx'), ]), ]) ] diff --git a/app/routes/_data.acls._index/cm.client.tsx b/app/routes/acls/components/cm.client.tsx similarity index 100% rename from app/routes/_data.acls._index/cm.client.tsx rename to app/routes/acls/components/cm.client.tsx diff --git a/app/routes/_data.acls._index/error.tsx b/app/routes/acls/components/error.tsx similarity index 100% rename from app/routes/_data.acls._index/error.tsx rename to app/routes/acls/components/error.tsx diff --git a/app/routes/_data.acls._index/fallback.tsx b/app/routes/acls/components/fallback.tsx similarity index 100% rename from app/routes/_data.acls._index/fallback.tsx rename to app/routes/acls/components/fallback.tsx diff --git a/app/routes/_data.acls._index/unavailable.tsx b/app/routes/acls/components/unavailable.tsx similarity index 100% rename from app/routes/_data.acls._index/unavailable.tsx rename to app/routes/acls/components/unavailable.tsx diff --git a/app/routes/_data.acls._index/route.tsx b/app/routes/acls/editor.tsx similarity index 98% rename from app/routes/_data.acls._index/route.tsx rename to app/routes/acls/editor.tsx index 31376e5..14f850b 100644 --- a/app/routes/_data.acls._index/route.tsx +++ b/app/routes/acls/editor.tsx @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-non-null-assertion */ import { BeakerIcon, EyeIcon, IssueDraftIcon, PencilIcon } from '@primer/octicons-react' import { ActionFunctionArgs, LoaderFunctionArgs } from '@remix-run/node' import { useLoaderData, useRevalidator } from '@remix-run/react' @@ -21,9 +20,9 @@ import { getSession } from '~/utils/sessions' import { send } from '~/utils/res' import log from '~/utils/log' -import { Editor, Differ } from './cm.client' -import { Unavailable } from './unavailable' -import { ErrorView } from './error' +import { Editor, Differ } from './components/cm.client' +import { Unavailable } from './components/unavailable' +import { ErrorView } from './components/error' export async function loader({ request }: LoaderFunctionArgs) { const session = await getSession(request.headers.get('Cookie')) diff --git a/app/routes/_data.dns._index/dns.tsx b/app/routes/dns/components/dns.tsx similarity index 98% rename from app/routes/_data.dns._index/dns.tsx rename to app/routes/dns/components/dns.tsx index 0c6b0cf..742c219 100644 --- a/app/routes/_data.dns._index/dns.tsx +++ b/app/routes/dns/components/dns.tsx @@ -6,7 +6,7 @@ import Link from '~/components/Link' import TableList from '~/components/TableList' import { cn } from '~/utils/cn' -import AddDNS from './dialogs/dns' +import AddDNS from '../dialogs/dns' interface Props { records: { name: string, type: 'A', value: string }[] diff --git a/app/routes/_data.dns._index/domains.tsx b/app/routes/dns/components/domains.tsx similarity index 98% rename from app/routes/_data.dns._index/domains.tsx rename to app/routes/dns/components/domains.tsx index cb48cf3..6b3493b 100644 --- a/app/routes/_data.dns._index/domains.tsx +++ b/app/routes/dns/components/domains.tsx @@ -16,7 +16,7 @@ import { } from '@dnd-kit/sortable' import { CSS } from '@dnd-kit/utilities' import { LockIcon, ThreeBarsIcon } from '@primer/octicons-react' -import { type FetcherWithComponents, useFetcher } from '@remix-run/react' +import { FetcherWithComponents, useFetcher } from '@remix-run/react' import { useEffect, useState } from 'react' import { Button, Input } from 'react-aria-components' diff --git a/app/routes/_data.dns._index/magic.tsx b/app/routes/dns/components/magic.tsx similarity index 96% rename from app/routes/_data.dns._index/magic.tsx rename to app/routes/dns/components/magic.tsx index acfa31e..2002abe 100644 --- a/app/routes/_data.dns._index/magic.tsx +++ b/app/routes/dns/components/magic.tsx @@ -5,7 +5,6 @@ import Spinner from '~/components/Spinner' type Properties = { readonly isEnabled: boolean; - // eslint-disable-next-line react/boolean-prop-naming readonly disabled?: boolean; } diff --git a/app/routes/_data.dns._index/nameservers.tsx b/app/routes/dns/components/nameservers.tsx similarity index 98% rename from app/routes/_data.dns._index/nameservers.tsx rename to app/routes/dns/components/nameservers.tsx index b40f4bb..837766a 100644 --- a/app/routes/_data.dns._index/nameservers.tsx +++ b/app/routes/dns/components/nameservers.tsx @@ -7,7 +7,7 @@ import Switch from '~/components/Switch' import TableList from '~/components/TableList' import { cn } from '~/utils/cn' -import AddNameserver from './dialogs/nameserver' +import AddNameserver from '../dialogs/nameserver' interface Props { nameservers: Record diff --git a/app/routes/_data.dns._index/rename.tsx b/app/routes/dns/components/rename.tsx similarity index 93% rename from app/routes/_data.dns._index/rename.tsx rename to app/routes/dns/components/rename.tsx index 0367b12..1f6d4f7 100644 --- a/app/routes/_data.dns._index/rename.tsx +++ b/app/routes/dns/components/rename.tsx @@ -1,5 +1,3 @@ -/* eslint-disable @typescript-eslint/naming-convention */ -/* eslint-disable unicorn/no-keyword-prefix */ import { useFetcher } from '@remix-run/react' import { useState } from 'react' import { Input } from 'react-aria-components' @@ -12,7 +10,6 @@ import { cn } from '~/utils/cn' type Properties = { readonly name: string; - // eslint-disable-next-line react/boolean-prop-naming readonly disabled?: boolean; } diff --git a/app/routes/_data.dns._index/dialogs/dns.tsx b/app/routes/dns/dialogs/dns.tsx similarity index 100% rename from app/routes/_data.dns._index/dialogs/dns.tsx rename to app/routes/dns/dialogs/dns.tsx diff --git a/app/routes/_data.dns._index/dialogs/nameserver.tsx b/app/routes/dns/dialogs/nameserver.tsx similarity index 100% rename from app/routes/_data.dns._index/dialogs/nameserver.tsx rename to app/routes/dns/dialogs/nameserver.tsx diff --git a/app/routes/_data.dns._index/route.tsx b/app/routes/dns/overview.tsx similarity index 91% rename from app/routes/_data.dns._index/route.tsx rename to app/routes/dns/overview.tsx index 808edbe..6fa2a03 100644 --- a/app/routes/_data.dns._index/route.tsx +++ b/app/routes/dns/overview.tsx @@ -1,4 +1,4 @@ -import { type ActionFunctionArgs } from '@remix-run/node' +import { ActionFunctionArgs } from '@remix-run/node' import { json, useLoaderData } from '@remix-run/react' import Code from '~/components/Code' @@ -8,11 +8,11 @@ import { loadConfig, patchConfig } from '~/utils/config/headscale' import { getSession } from '~/utils/sessions' import { useLiveData } from '~/utils/useLiveData' -import DNS from './dns' -import Domains from './domains' -import MagicModal from './magic' -import Nameservers from './nameservers' -import RenameModal from './rename' +import DNS from './components/dns' +import Domains from './components/domains' +import MagicModal from './components/magic' +import Nameservers from './components/nameservers' +import RenameModal from './components/rename' // We do not want to expose every config value export async function loader() { diff --git a/app/routes/_data.machines._index/action.tsx b/app/routes/machines/action.tsx similarity index 100% rename from app/routes/_data.machines._index/action.tsx rename to app/routes/machines/action.tsx diff --git a/app/routes/_data.machines._index/machine.tsx b/app/routes/machines/components/machine.tsx similarity index 100% rename from app/routes/_data.machines._index/machine.tsx rename to app/routes/machines/components/machine.tsx diff --git a/app/routes/_data.machines._index/menu.tsx b/app/routes/machines/components/menu.tsx similarity index 91% rename from app/routes/_data.machines._index/menu.tsx rename to app/routes/machines/components/menu.tsx index 2f38648..a519e69 100644 --- a/app/routes/_data.machines._index/menu.tsx +++ b/app/routes/machines/components/menu.tsx @@ -5,12 +5,12 @@ import MenuComponent from '~/components/Menu' import { Machine, Route, User } from '~/types' import { cn } from '~/utils/cn' -import Delete from './dialogs/delete' -import Expire from './dialogs/expire' -import Move from './dialogs/move' -import Rename from './dialogs/rename' -import Routes from './dialogs/routes' -import Tags from './dialogs/tags' +import Delete from '../dialogs/delete' +import Expire from '../dialogs/expire' +import Move from '../dialogs/move' +import Rename from '../dialogs/rename' +import Routes from '../dialogs/routes' +import Tags from '../dialogs/tags' interface MenuProps { machine: Machine diff --git a/app/routes/_data.machines._index/dialogs/delete.tsx b/app/routes/machines/dialogs/delete.tsx similarity index 100% rename from app/routes/_data.machines._index/dialogs/delete.tsx rename to app/routes/machines/dialogs/delete.tsx diff --git a/app/routes/_data.machines._index/dialogs/expire.tsx b/app/routes/machines/dialogs/expire.tsx similarity index 100% rename from app/routes/_data.machines._index/dialogs/expire.tsx rename to app/routes/machines/dialogs/expire.tsx diff --git a/app/routes/_data.machines._index/dialogs/move.tsx b/app/routes/machines/dialogs/move.tsx similarity index 100% rename from app/routes/_data.machines._index/dialogs/move.tsx rename to app/routes/machines/dialogs/move.tsx diff --git a/app/routes/_data.machines._index/dialogs/new.tsx b/app/routes/machines/dialogs/new.tsx similarity index 100% rename from app/routes/_data.machines._index/dialogs/new.tsx rename to app/routes/machines/dialogs/new.tsx diff --git a/app/routes/_data.machines._index/dialogs/rename.tsx b/app/routes/machines/dialogs/rename.tsx similarity index 100% rename from app/routes/_data.machines._index/dialogs/rename.tsx rename to app/routes/machines/dialogs/rename.tsx diff --git a/app/routes/_data.machines._index/dialogs/routes.tsx b/app/routes/machines/dialogs/routes.tsx similarity index 100% rename from app/routes/_data.machines._index/dialogs/routes.tsx rename to app/routes/machines/dialogs/routes.tsx diff --git a/app/routes/_data.machines._index/dialogs/tags.tsx b/app/routes/machines/dialogs/tags.tsx similarity index 100% rename from app/routes/_data.machines._index/dialogs/tags.tsx rename to app/routes/machines/dialogs/tags.tsx diff --git a/app/routes/_data.machines.$id/route.tsx b/app/routes/machines/machine.tsx similarity index 97% rename from app/routes/_data.machines.$id/route.tsx rename to app/routes/machines/machine.tsx index 62ad1c4..3ee7644 100644 --- a/app/routes/_data.machines.$id/route.tsx +++ b/app/routes/machines/machine.tsx @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-non-null-assertion */ import { ActionFunctionArgs, LoaderFunctionArgs } from '@remix-run/node' import { Link as RemixLink, useLoaderData } from '@remix-run/react' import { InfoIcon, GearIcon, CheckCircleIcon, SkipIcon, PersonIcon } from '@primer/octicons-react' @@ -19,9 +18,9 @@ import { getSession } from '~/utils/sessions' import { useLiveData } from '~/utils/useLiveData' import Link from '~/components/Link' -import { menuAction } from '../_data.machines._index/action' -import MenuOptions from '../_data.machines._index/menu' -import Routes from '../_data.machines._index/dialogs/routes' +import { menuAction } from './action' +import MenuOptions from './components/menu' +import Routes from './dialogs/routes' export async function loader({ request, params }: LoaderFunctionArgs) { const session = await getSession(request.headers.get('Cookie')) diff --git a/app/routes/_data.machines._index/route.tsx b/app/routes/machines/overview.tsx similarity index 97% rename from app/routes/_data.machines._index/route.tsx rename to app/routes/machines/overview.tsx index 6c9b7d9..2467d45 100644 --- a/app/routes/_data.machines._index/route.tsx +++ b/app/routes/machines/overview.tsx @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-non-null-assertion */ import { InfoIcon } from '@primer/octicons-react' import { ActionFunctionArgs, LoaderFunctionArgs } from '@remix-run/node' import { useLoaderData } from '@remix-run/react' @@ -15,7 +14,7 @@ import { useLiveData } from '~/utils/useLiveData' import type { Machine, Route, User } from '~/types' import { menuAction } from './action' -import MachineRow from './machine' +import MachineRow from './components/machine' import NewMachine from './dialogs/new' export async function loader({ request }: LoaderFunctionArgs) { diff --git a/app/routes/_data.settings.auth-keys._index/route.tsx b/app/routes/settings/auth-keys.tsx similarity index 99% rename from app/routes/_data.settings.auth-keys._index/route.tsx rename to app/routes/settings/auth-keys.tsx index ff409b7..9470bb1 100644 --- a/app/routes/_data.settings.auth-keys._index/route.tsx +++ b/app/routes/settings/auth-keys.tsx @@ -15,7 +15,7 @@ import Select from '~/components/Select' import Switch from '~/components/Switch' import AddPreAuthKey from './dialogs/new' -import AuthKeyRow from './key' +import AuthKeyRow from './components/key' export async function action({ request }: ActionFunctionArgs) { const session = await getSession(request.headers.get('Cookie')) diff --git a/app/routes/_data.settings.auth-keys._index/key.tsx b/app/routes/settings/components/key.tsx similarity index 97% rename from app/routes/_data.settings.auth-keys._index/key.tsx rename to app/routes/settings/components/key.tsx index 0af61c7..0dcb2cf 100644 --- a/app/routes/_data.settings.auth-keys._index/key.tsx +++ b/app/routes/settings/components/key.tsx @@ -4,7 +4,7 @@ import { toast } from '~/components/Toaster' import Code from '~/components/Code' import Button from '~/components/Button' import Attribute from '~/components/Attribute' -import ExpireKey from './dialogs/expire' +import ExpireKey from '../dialogs/expire' interface Props { authKey: PreAuthKey diff --git a/app/routes/_data.settings.auth-keys._index/dialogs/expire.tsx b/app/routes/settings/dialogs/expire.tsx similarity index 100% rename from app/routes/_data.settings.auth-keys._index/dialogs/expire.tsx rename to app/routes/settings/dialogs/expire.tsx diff --git a/app/routes/_data.settings.auth-keys._index/dialogs/new.tsx b/app/routes/settings/dialogs/new.tsx similarity index 100% rename from app/routes/_data.settings.auth-keys._index/dialogs/new.tsx rename to app/routes/settings/dialogs/new.tsx diff --git a/app/routes/_data.settings._index/route.tsx b/app/routes/settings/overview.tsx similarity index 100% rename from app/routes/_data.settings._index/route.tsx rename to app/routes/settings/overview.tsx diff --git a/app/routes/_data.users._index/auth.tsx b/app/routes/users/components/auth.tsx similarity index 97% rename from app/routes/_data.users._index/auth.tsx rename to app/routes/users/components/auth.tsx index 689dce0..1e8e62f 100644 --- a/app/routes/_data.users._index/auth.tsx +++ b/app/routes/users/components/auth.tsx @@ -3,7 +3,7 @@ import { HomeIcon, PasskeyFillIcon } from '@primer/octicons-react' import Card from '~/components/Card' import Link from '~/components/Link' -import Add from './add' +import Add from '../dialogs/add' interface Props { readonly magic: string | undefined diff --git a/app/routes/_data.users._index/oidc.tsx b/app/routes/users/components/oidc.tsx similarity index 98% rename from app/routes/_data.users._index/oidc.tsx rename to app/routes/users/components/oidc.tsx index 08a36f8..ee44b89 100644 --- a/app/routes/_data.users._index/oidc.tsx +++ b/app/routes/users/components/oidc.tsx @@ -4,7 +4,7 @@ import Card from '~/components/Card' import Link from '~/components/Link' import { HeadplaneContext } from '~/utils/config/headplane' -import Add from './add' +import Add from '../dialogs/add' interface Props { readonly oidc: NonNullable diff --git a/app/routes/_data.users._index/add.tsx b/app/routes/users/dialogs/add.tsx similarity index 100% rename from app/routes/_data.users._index/add.tsx rename to app/routes/users/dialogs/add.tsx diff --git a/app/routes/_data.users._index/remove.tsx b/app/routes/users/dialogs/remove.tsx similarity index 100% rename from app/routes/_data.users._index/remove.tsx rename to app/routes/users/dialogs/remove.tsx diff --git a/app/routes/_data.users._index/rename.tsx b/app/routes/users/dialogs/rename.tsx similarity index 100% rename from app/routes/_data.users._index/rename.tsx rename to app/routes/users/dialogs/rename.tsx diff --git a/app/routes/_data.users._index/route.tsx b/app/routes/users/overview.tsx similarity index 97% rename from app/routes/_data.users._index/route.tsx rename to app/routes/users/overview.tsx index 4d2a4ae..237e2e5 100644 --- a/app/routes/_data.users._index/route.tsx +++ b/app/routes/users/overview.tsx @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-non-null-assertion */ import { DataRef, DndContext, useDraggable, useDroppable } from '@dnd-kit/core' import { PersonIcon } from '@primer/octicons-react' import { ActionFunctionArgs, LoaderFunctionArgs } from '@remix-run/node' @@ -19,10 +18,10 @@ import { getSession } from '~/utils/sessions' import { useLiveData } from '~/utils/useLiveData' import { send } from '~/utils/res' -import Auth from './auth' -import Oidc from './oidc' -import Remove from './remove' -import Rename from './rename' +import Auth from './components/auth' +import Oidc from './components/oidc' +import Remove from './dialogs/remove' +import Rename from './dialogs/rename' export async function loader({ request }: LoaderFunctionArgs) { const session = await getSession(request.headers.get('Cookie')) diff --git a/app/routes/healthz.tsx b/app/routes/util/healthz.ts similarity index 63% rename from app/routes/healthz.tsx rename to app/routes/util/healthz.ts index df2bb0e..0e80103 100644 --- a/app/routes/healthz.tsx +++ b/app/routes/util/healthz.ts @@ -1,5 +1,6 @@ import { loadContext } from '~/utils/config/headplane' import { HeadscaleError, pull } from '~/utils/headscale' +import { data } from '@remix-run/node' import log from '~/utils/log' export async function loader() { @@ -11,19 +12,12 @@ export async function loader() { } catch (e) { if (!(e instanceof HeadscaleError)) { log.debug('Healthz', 'Headscale is not reachable') - return new Response('Headscale is not reachable', { - status: 500, - headers: { - 'Content-Type': 'text/plain', - }, - }) + return data({ + status: 'NOT OK', + error: e.message + }, { status: 500 }) } } - return new Response('OK', { - status: 200, - headers: { - 'Content-Type': 'text/plain', - }, - }) + return { status: 'OK' } } diff --git a/app/routes/_index.tsx b/app/routes/util/redirect.ts similarity index 69% rename from app/routes/_index.tsx rename to app/routes/util/redirect.ts index 556470b..9f3f621 100644 --- a/app/routes/_index.tsx +++ b/app/routes/util/redirect.ts @@ -1,5 +1,5 @@ import { redirect } from '@remix-run/node' -export function loader() { +export async function loader() { return redirect('/machines') }