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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { insertGitHubUser, deleteGitHubUsers } from '#tests/mocks/github.ts'
import { server } from '#tests/mocks/index.ts'
import { consoleError } from '#tests/setup/setup-test-env.ts'
import { BASE_URL, convertSetCookieToCookie } from '#tests/utils.ts'
import { loader } from './auth.$provider.callback.ts'
import { loader } from './callback.ts'

const ROUTE_PATH = '/auth/github/callback'
const PARAMS = { provider: 'github' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import {
redirectWithToast,
} from '#app/utils/toast.server.ts'
import { verifySessionStorage } from '#app/utils/verification.server.ts'
import { type Route } from './+types/auth.$provider.callback.ts'
import { handleNewSession } from './login.server.ts'
import { onboardingEmailSessionKey } from './onboarding.tsx'
import { prefilledProfileKey, providerIdKey } from './onboarding_.$provider.tsx'
import { handleNewSession } from '../login.server.ts'
import { prefilledProfileKey, providerIdKey } from '../onboarding/$provider.tsx'
import { onboardingEmailSessionKey } from '../onboarding/index.tsx'
import { type Route } from './+types/callback.ts'

const destroyRedirectTo = { 'set-cookie': destroyRedirectToHeader }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { handleMockAction } from '#app/utils/connections.server.ts'
import { ProviderNameSchema } from '#app/utils/connections.tsx'
import { getReferrerRoute } from '#app/utils/misc.tsx'
import { getRedirectCookieHeader } from '#app/utils/redirect-cookie.server.ts'
import { type Route } from './+types/auth_.$provider.ts'
import { type Route } from './+types/index.ts'

export async function loader() {
return redirect('/login')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { invariant } from '@epic-web/invariant'
import { redirect } from 'react-router'
import { verifySessionStorage } from '#app/utils/verification.server.ts'
import { onboardingEmailSessionKey } from './onboarding.tsx'
import { type VerifyFunctionArgs } from './verify.server.ts'
import { type VerifyFunctionArgs } from '../verify.server.ts'
import { onboardingEmailSessionKey } from './index.tsx'

export async function handleVerification({ submission }: VerifyFunctionArgs) {
invariant(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import { authSessionStorage } from '#app/utils/session.server.ts'
import { redirectWithToast } from '#app/utils/toast.server.ts'
import { NameSchema, UsernameSchema } from '#app/utils/user-validation.ts'
import { verifySessionStorage } from '#app/utils/verification.server.ts'
import { type Route } from './+types/onboarding_.$provider.ts'
import { onboardingEmailSessionKey } from './onboarding'
import { type Route } from './+types/$provider.ts'
import { onboardingEmailSessionKey } from './index.tsx'

export const providerIdKey = 'providerId'
export const prefilledProfileKey = 'prefilledProfile'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { invariant } from '@epic-web/invariant'
import { redirect } from 'react-router'
import { verifySessionStorage } from '#app/utils/verification.server.ts'
import { onboardingEmailSessionKey } from './onboarding.tsx'
import { type VerifyFunctionArgs } from './verify.server.ts'
import { type VerifyFunctionArgs } from '../verify.server.ts'
import { onboardingEmailSessionKey } from './index.tsx'

export async function handleVerification({ submission }: VerifyFunctionArgs) {
invariant(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
UsernameSchema,
} from '#app/utils/user-validation.ts'
import { verifySessionStorage } from '#app/utils/verification.server.ts'
import { type Route } from './+types/onboarding.ts'
import { type Route } from './+types/index.ts'

export const onboardingEmailSessionKey = 'onboardingEmail'

Expand Down
2 changes: 1 addition & 1 deletion app/routes/_auth/verify.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
handleVerification as handleLoginTwoFactorVerification,
shouldRequestTwoFA,
} from './login.server.ts'
import { handleVerification as handleOnboardingVerification } from './onboarding.server.ts'
import { handleVerification as handleOnboardingVerification } from './onboarding/index.server.ts'
import { handleVerification as handleResetPasswordVerification } from './reset-password.server.ts'
import {
VerifySchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
} from '#app/utils/litefs.server.ts'
import { useDebounce, useDoubleCheck } from '#app/utils/misc.tsx'
import { requireUserWithRole } from '#app/utils/permissions.server.ts'
import { type Route } from './+types/cache.ts'
import { type Route } from './+types/index.ts'

export const handle: SEOHandle = {
getSitemapEntries: () => null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
ensureInstance,
} from '#app/utils/litefs.server.ts'
import { requireUserWithRole } from '#app/utils/permissions.server.ts'
import { type Route } from './+types/cache_.lru.$cacheKey.ts'
import { type Route } from './+types/lru.$cacheKey.ts'

export async function loader({ request, params }: Route.LoaderArgs) {
await requireUserWithRole(request, 'admin')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
ensureInstance,
} from '#app/utils/litefs.server.ts'
import { requireUserWithRole } from '#app/utils/permissions.server.ts'
import { type Route } from './+types/cache_.sqlite.$cacheKey.ts'
import { type Route } from './+types/sqlite.$cacheKey.ts'

export async function loader({ request, params }: Route.LoaderArgs) {
await requireUserWithRole(request, 'admin')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
getInstanceInfo,
getInternalInstanceDomain,
} from '#app/utils/litefs.server'
import { type Route } from './+types/cache_.sqlite.ts'
import { type Route } from './+types/sqlite.ts'

export async function updatePrimaryCacheValue({
key,
Expand Down
1 change: 1 addition & 0 deletions app/routes/admin/cache/sqlite.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { action } from './sqlite.server.ts'
1 change: 0 additions & 1 deletion app/routes/admin/cache_.sqlite.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export function DeleteNote({

export const meta: Route.MetaFunction = ({ data, params, matches }) => {
const notesMatch = matches.find(
(m) => m?.id === 'routes/users/$username_/notes',
(m) => m?.id === 'routes/users/$username/notes',
) as { data: NotesRoute.ComponentProps['loaderData'] } | undefined

const displayName = notesMatch?.data?.owner.name ?? params.username
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function NotesIndexRoute() {

export const meta: Route.MetaFunction = ({ params, matches }) => {
const notesMatch = matches.find(
(m) => m?.id === 'routes/users/$username_/notes',
(m) => m?.id === 'routes/users/$username/notes',
) as { data: NotesRoute.ComponentProps['loaderData'] }

const displayName = notesMatch?.data?.owner.name ?? params.username
Expand Down
2 changes: 1 addition & 1 deletion app/utils/cache.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import { remember } from '@epic-web/remember'
import { LRUCache } from 'lru-cache'
import { z } from 'zod'
import { updatePrimaryCacheValue } from '#app/routes/admin/cache_.sqlite.server.ts'
import { updatePrimaryCacheValue } from '#app/routes/admin/cache/sqlite.server.ts'
import { getInstanceInfo, getInstanceInfoSync } from './litefs.server.ts'
import { cachifiedTimingReporter, type Timings } from './timing.server.ts'

Expand Down
81 changes: 44 additions & 37 deletions docs/routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,41 @@ of the Epic Stack routes at the time of this writing:
```
app/routes
├── $.tsx
├── me.tsx
├── _auth
│ ├── auth.$provider.callback.ts
│ ├── auth_.$provider.ts
│ ├── forgot-password.tsx
│ ├── login.tsx
│ ├── logout.tsx
│ ├── onboarding.tsx
│ ├── onboarding_.$provider.tsx
│ ├── reset-password.tsx
│ ├── signup.tsx
│ ├── verify.tsx
│ ├── auth.$provider
│ │ ├── callback.ts
│ │ └── index.ts
│ ├── onboarding
│ │ ├── $provider.tsx
│ │ └── index.tsx
│ └── webauthn
│ ├── authentication.ts
│ └── registration.ts
├── _marketing
│ ├── +logos
│ │ ├── logos.ts
│ │ └── ...
│ ├── about.tsx
│ ├── index.tsx
│ ├── privacy.tsx
│ ├── support.tsx
│ └── tos.tsx
│ ├── tos.tsx
│ └── +logos
│ ├── logos.ts
│ └── ...
├── _seo
│ ├── robots[.]txt.ts
│ └── sitemap[.]xml.ts
├── admin
── cache.tsx
│ ├── cache_.lru.$cacheKey.ts
│ ├── cache_.sqlite.$cacheKey.ts
── cache_.sqlite.tsx
── me.tsx
── cache
├── index.tsx
├── lru.$cacheKey.ts
── sqlite.$cacheKey.ts
│ └── sqlite.tsx
├── resources
│ ├── download-user-data.tsx
│ ├── healthcheck.tsx
Expand All @@ -70,17 +73,17 @@ app/routes
│ ├── index.tsx
│ └── verify.tsx
└── users
├── $username_
│ ├── index.tsx
── notes
── $noteId.tsx
├── $noteId_.edit.tsx
├── _layout.tsx
├── index.tsx
── new.tsx
└── index.tsx
├── index.tsx
── $username
── index.tsx
── notes
├── $noteId.tsx
├── $noteId_.edit.tsx
├── _layout.tsx
── index.tsx
└── new.tsx

13 directories, 49 files
17 directories, 72 files
```

```tsx
Expand All @@ -89,17 +92,21 @@ app/routes
<Route path="*" file="routes/$.tsx" />
<Route
path="auth/:provider/callback"
file="routes/_auth/auth.$provider.callback.ts"
file="routes/_auth/auth.$provider/callback.ts"
/>
<Route
path="auth/:provider"
index
file="routes/_auth/auth.$provider/index.ts"
/>
<Route path="auth/:provider" file="routes/_auth/auth_.$provider.ts" />
<Route path="forgot-password" file="routes/_auth/forgot-password.tsx" />
<Route path="login" file="routes/_auth/login.tsx" />
<Route path="logout" file="routes/_auth/logout.tsx" />
<Route path="onboarding" file="routes/_auth/onboarding.tsx" />
<Route
path="onboarding/:provider"
file="routes/_auth/onboarding_.$provider.tsx"
file="routes/_auth/onboarding/$provider.tsx"
/>
<Route path="onboarding" index file="routes/_auth/onboarding/index.tsx" />
<Route path="reset-password" file="routes/_auth/reset-password.tsx" />
<Route path="signup" file="routes/_auth/signup.tsx" />
<Route path="verify" file="routes/_auth/verify.tsx" />
Expand All @@ -118,13 +125,13 @@ app/routes
<Route path="tos" file="routes/_marketing/tos.tsx" />
<Route path="robots.txt" file="routes/_seo/robots[.]txt.ts" />
<Route path="sitemap.xml" file="routes/_seo/sitemap[.]xml.ts" />
<Route path="admin/cache" file="routes/admin/cache.tsx" />
<Route path="admin/cache" index file="routes/admin/cache/index.tsx" />
<Route
path="admin/cache/lru/:cacheKey"
file="routes/admin/cache_.lru.$cacheKey.ts"
file="routes/admin/cache/lru.$cacheKey.ts"
/>
<Route path="admin/cache/sqlite" file="routes/admin/cache_.sqlite.tsx">
<Route path=":cacheKey" file="routes/admin/cache_.sqlite.$cacheKey.ts" />
<Route path="admin/cache/sqlite" file="routes/admin/cache/sqlite.tsx">
<Route path=":cacheKey" file="routes/admin/cache/sqlite.$cacheKey.ts" />
</Route>
<Route path="me" file="routes/me.tsx" />
<Route
Expand Down Expand Up @@ -175,19 +182,19 @@ app/routes
<Route
path="users/:username"
index
file="routes/users/$username_/index.tsx"
file="routes/users/$username/index.tsx"
/>
<Route
path="users/:username/notes"
file="routes/users/$username_/notes/_layout.tsx"
file="routes/users/$username/notes/_layout.tsx"
>
<Route path=":noteId" file="routes/users/$username_/notes/$noteId.tsx" />
<Route path=":noteId" file="routes/users/$username/notes/$noteId.tsx" />
<Route
path=":noteId/edit"
file="routes/users/$username_/notes/$noteId_.edit.tsx"
file="routes/users/$username/notes/$noteId_.edit.tsx"
/>
<Route index file="routes/users/$username_/notes/index.tsx" />
<Route path="new" file="routes/users/$username_/notes/new.tsx" />
<Route index file="routes/users/$username/notes/index.tsx" />
<Route path="new" file="routes/users/$username/notes/new.tsx" />
</Route>
<Route path="users" index file="routes/users/index.tsx" />
</Route>
Expand Down