Skip to content

Commit 64ac625

Browse files
committed
Migrate to typelizer routes
1 parent a3711d7 commit 64ac625

39 files changed

Lines changed: 445 additions & 1554 deletions

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ gem "inertia_rails", "~> 3.19"
4747
gem "authentication-zero"
4848

4949
# Brings Rails named routes to javascript
50-
gem "js-routes"
50+
gem "typelizer"
5151

5252
group :development, :test do
5353
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem

Gemfile.lock

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,10 @@ GEM
8282
base64 (0.3.0)
8383
bcrypt (3.1.22)
8484
bcrypt_pbkdf (1.1.2)
85+
benchmark (0.5.0)
8586
bigdecimal (4.1.2)
8687
bindex (0.8.1)
87-
bootsnap (1.23.0)
88+
bootsnap (1.24.1)
8889
msgpack (~> 1.2)
8990
brakeman (8.0.4)
9091
racc
@@ -145,9 +146,6 @@ GEM
145146
jbuilder (2.14.1)
146147
actionview (>= 7.0.0)
147148
activesupport (>= 7.0.0)
148-
js-routes (2.3.6)
149-
railties (>= 5)
150-
sorbet-runtime
151149
json (2.19.4)
152150
kamal (2.11.0)
153151
activesupport (>= 7.0)
@@ -181,12 +179,12 @@ GEM
181179
marcel (1.1.0)
182180
matrix (0.4.3)
183181
mini_mime (1.1.5)
184-
minitest (6.0.5)
182+
minitest (6.0.6)
185183
drb (~> 2.0)
186184
prism (~> 1.5)
187185
msgpack (1.8.0)
188186
mutex_m (0.3.0)
189-
net-imap (0.6.3)
187+
net-imap (0.6.4)
190188
date
191189
net-protocol
192190
net-pop (0.1.2)
@@ -201,22 +199,22 @@ GEM
201199
net-protocol
202200
net-ssh (7.3.2)
203201
nio4r (2.7.5)
204-
nokogiri (1.19.2-aarch64-linux-gnu)
202+
nokogiri (1.19.3-aarch64-linux-gnu)
205203
racc (~> 1.4)
206-
nokogiri (1.19.2-aarch64-linux-musl)
204+
nokogiri (1.19.3-aarch64-linux-musl)
207205
racc (~> 1.4)
208-
nokogiri (1.19.2-arm-linux-gnu)
206+
nokogiri (1.19.3-arm-linux-gnu)
209207
racc (~> 1.4)
210-
nokogiri (1.19.2-arm-linux-musl)
208+
nokogiri (1.19.3-arm-linux-musl)
211209
racc (~> 1.4)
212-
nokogiri (1.19.2-arm64-darwin)
210+
nokogiri (1.19.3-arm64-darwin)
213211
racc (~> 1.4)
214-
nokogiri (1.19.2-x86_64-linux-gnu)
212+
nokogiri (1.19.3-x86_64-linux-gnu)
215213
racc (~> 1.4)
216-
nokogiri (1.19.2-x86_64-linux-musl)
214+
nokogiri (1.19.3-x86_64-linux-musl)
217215
racc (~> 1.4)
218216
ostruct (0.6.3)
219-
parallel (2.0.1)
217+
parallel (2.1.0)
220218
parser (3.3.11.1)
221219
ast (~> 2.4.1)
222220
racc
@@ -232,7 +230,7 @@ GEM
232230
date
233231
stringio
234232
public_suffix (7.0.5)
235-
puma (8.0.0)
233+
puma (8.0.1)
236234
nio4r (~> 2.0)
237235
raabro (1.4.0)
238236
racc (1.8.1)
@@ -356,7 +354,6 @@ GEM
356354
fugit (~> 1.11)
357355
railties (>= 7.1)
358356
thor (>= 1.3.1)
359-
sorbet-runtime (0.6.13153)
360357
sqlite3 (2.9.3-aarch64-linux-gnu)
361358
sqlite3 (2.9.3-aarch64-linux-musl)
362359
sqlite3 (2.9.3-arm-linux-gnu)
@@ -379,6 +376,9 @@ GEM
379376
thruster (0.1.20-x86_64-linux)
380377
timeout (0.6.1)
381378
tsort (0.2.0)
379+
typelizer (0.13.0)
380+
benchmark
381+
railties (>= 6.1.0)
382382
tzinfo (2.0.6)
383383
concurrent-ruby (~> 1.0)
384384
unicode-display_width (3.2.0)
@@ -431,7 +431,6 @@ DEPENDENCIES
431431
factory_bot_rails
432432
inertia_rails (~> 3.19)
433433
jbuilder
434-
js-routes
435434
kamal
436435
letter_opener
437436
propshaft
@@ -445,6 +444,7 @@ DEPENDENCIES
445444
solid_queue
446445
sqlite3 (>= 2.1)
447446
thruster
447+
typelizer
448448
tzinfo-data
449449
vite_rails (~> 3.0)
450450
web-console

app/frontend/components/app-header.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import {
3232
import { UserMenuContent } from "@/components/user-menu-content"
3333
import { useInitials } from "@/hooks/use-initials"
3434
import { cn } from "@/lib/utils"
35-
import { dashboardPath } from "@/routes"
35+
import { dashboard } from "@/routes"
3636
import type { BreadcrumbItem, NavItem } from "@/types"
3737

3838
import AppLogo from "./app-logo"
@@ -41,7 +41,7 @@ import AppLogoIcon from "./app-logo-icon"
4141
const mainNavItems: NavItem[] = [
4242
{
4343
title: "Dashboard",
44-
href: dashboardPath(),
44+
href: dashboard.index().url,
4545
icon: LayoutGrid,
4646
},
4747
]
@@ -134,7 +134,7 @@ export function AppHeader({ breadcrumbs = [] }: AppHeaderProps) {
134134
</div>
135135

136136
<Link
137-
href={dashboardPath()}
137+
href={dashboard.index()}
138138
prefetch
139139
className="flex items-center space-x-2"
140140
>

app/frontend/components/app-sidebar.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ import {
1313
SidebarMenuButton,
1414
SidebarMenuItem,
1515
} from "@/components/ui/sidebar"
16-
import { dashboardPath } from "@/routes"
16+
import { dashboard } from "@/routes"
1717
import type { NavItem } from "@/types"
1818

1919
import AppLogo from "./app-logo"
2020

2121
const mainNavItems: NavItem[] = [
2222
{
2323
title: "Dashboard",
24-
href: dashboardPath(),
24+
href: dashboard.index().url,
2525
icon: LayoutGrid,
2626
},
2727
]
@@ -46,7 +46,7 @@ export function AppSidebar() {
4646
<SidebarMenu>
4747
<SidebarMenuItem>
4848
<SidebarMenuButton size="lg" asChild>
49-
<Link href={dashboardPath()} prefetch>
49+
<Link href={dashboard.index()} prefetch>
5050
<AppLogo />
5151
</Link>
5252
</SidebarMenuButton>

app/frontend/components/delete-user.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
} from "@/components/ui/dialog"
1515
import { Field, FieldError, FieldLabel } from "@/components/ui/field"
1616
import { Input } from "@/components/ui/input"
17-
import { usersPath } from "@/routes"
17+
import { users } from "@/routes"
1818

1919
export default function DeleteUser() {
2020
const passwordInput = useRef<HTMLInputElement>(null)
@@ -47,8 +47,7 @@ export default function DeleteUser() {
4747
you would like to permanently delete your account.
4848
</DialogDescription>
4949
<Form
50-
method="delete"
51-
action={usersPath()}
50+
action={users.destroy()}
5251
options={{
5352
preserveScroll: true,
5453
}}

app/frontend/components/user-menu-content.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
} from "@/components/ui/dropdown-menu"
1010
import { UserInfo } from "@/components/user-info"
1111
import { useMobileNavigation } from "@/hooks/use-mobile-navigation"
12-
import { sessionPath, settingsProfilePath } from "@/routes"
12+
import { sessions, settingsProfiles } from "@/routes"
1313
import type { User } from "@/types"
1414

1515
interface UserMenuContentProps {
@@ -42,7 +42,7 @@ export function UserMenuContent({ auth }: UserMenuContentProps) {
4242
<DropdownMenuItem asChild>
4343
<Link
4444
className="block w-full"
45-
href={settingsProfilePath()}
45+
href={settingsProfiles.show()}
4646
as="button"
4747
prefetch
4848
onClick={cleanup}
@@ -56,8 +56,7 @@ export function UserMenuContent({ auth }: UserMenuContentProps) {
5656
<DropdownMenuItem asChild>
5757
<Link
5858
className="block w-full"
59-
method="delete"
60-
href={sessionPath({ id: session.id })}
59+
href={sessions.destroy(session.id)}
6160
as="button"
6261
onClick={handleLogout}
6362
>

app/frontend/layouts/auth/auth-card-layout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
CardHeader,
1010
CardTitle,
1111
} from "@/components/ui/card"
12-
import { rootPath } from "@/routes"
12+
import { home } from "@/routes"
1313

1414
export default function AuthCardLayout({
1515
children,
@@ -24,7 +24,7 @@ export default function AuthCardLayout({
2424
<div className="bg-muted flex min-h-svh flex-col items-center justify-center gap-6 p-6 md:p-10">
2525
<div className="flex w-full max-w-md flex-col gap-6">
2626
<Link
27-
href={rootPath()}
27+
href={home.index()}
2828
className="flex items-center gap-2 self-center font-medium"
2929
>
3030
<div className="flex h-9 w-9 items-center justify-center">

app/frontend/layouts/auth/auth-simple-layout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Link } from "@inertiajs/react"
22
import type { PropsWithChildren } from "react"
33

44
import AppLogoIcon from "@/components/app-logo-icon"
5-
import { rootPath } from "@/routes"
5+
import { home } from "@/routes"
66

77
interface AuthLayoutProps {
88
name?: string
@@ -21,7 +21,7 @@ export default function AuthSimpleLayout({
2121
<div className="flex flex-col gap-8">
2222
<div className="flex flex-col items-center gap-4">
2323
<Link
24-
href={rootPath()}
24+
href={home.index()}
2525
className="flex flex-col items-center gap-2 font-medium"
2626
>
2727
<div className="mb-1 flex size-14 items-center justify-center rounded-md">

app/frontend/layouts/auth/auth-split-layout.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Link } from "@inertiajs/react"
22
import type { PropsWithChildren } from "react"
33

44
import AppLogoIcon from "@/components/app-logo-icon"
5-
import { rootPath } from "@/routes"
5+
import { home } from "@/routes"
66

77
interface AuthLayoutProps {
88
title?: string
@@ -19,7 +19,7 @@ export default function AuthSplitLayout({
1919
<div className="bg-muted relative hidden h-full flex-col p-10 text-white lg:flex dark:border-r">
2020
<div className="absolute inset-0 bg-zinc-900" />
2121
<Link
22-
href={rootPath()}
22+
href={home.index()}
2323
className="relative z-20 flex items-center text-lg font-medium"
2424
>
2525
<AppLogoIcon className="mr-2 size-8 fill-current text-white" />
@@ -39,7 +39,7 @@ export default function AuthSplitLayout({
3939
<div className="w-full lg:p-8">
4040
<div className="mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[350px]">
4141
<Link
42-
href={rootPath()}
42+
href={home.index()}
4343
className="relative z-20 flex items-center justify-center lg:hidden"
4444
>
4545
<AppLogoIcon className="h-10 fill-current text-black sm:h-12" />

app/frontend/layouts/settings/layout.tsx

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,34 @@ import { Button } from "@/components/ui/button"
66
import { Separator } from "@/components/ui/separator"
77
import { cn } from "@/lib/utils"
88
import {
9-
settingsAppearancePath,
10-
settingsEmailPath,
11-
settingsPasswordPath,
12-
settingsProfilePath,
13-
settingsSessionsPath,
9+
settingsAppearance,
10+
settingsEmails,
11+
settingsPasswords,
12+
settingsProfiles,
13+
settingsSessions,
1414
} from "@/routes"
1515
import type { NavItem } from "@/types"
1616

1717
const sidebarNavItems: NavItem[] = [
1818
{
1919
title: "Profile",
20-
href: settingsProfilePath(),
21-
icon: null,
20+
href: settingsProfiles.show().url,
2221
},
2322
{
2423
title: "Email",
25-
href: settingsEmailPath(),
26-
icon: null,
24+
href: settingsEmails.show().url,
2725
},
2826
{
2927
title: "Password",
30-
href: settingsPasswordPath(),
31-
icon: null,
28+
href: settingsPasswords.show().url,
3229
},
3330
{
3431
title: "Sessions",
35-
href: settingsSessionsPath(),
36-
icon: null,
32+
href: settingsSessions.index().url,
3733
},
3834
{
3935
title: "Appearance",
40-
href: settingsAppearancePath(),
41-
icon: null,
36+
href: settingsAppearance().url,
4237
},
4338
]
4439

0 commit comments

Comments
 (0)