create-signet-app 0.2.2 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/README.md +128 -7
  2. package/package.json +4 -3
  3. package/src/index.ts +338 -66
  4. package/template-api/_github/workflows/ci.yml +0 -3
  5. package/template-api/_mcp/test/mcp-off.test.ts +13 -0
  6. package/template-api/_mcp/test/mcp.test.ts +49 -0
  7. package/template-api/_targets/bun/Dockerfile +13 -0
  8. package/template-api/_targets/bun/_dockerignore +10 -0
  9. package/template-api/_targets/bun/src/server.ts +32 -0
  10. package/template-api/_targets/cloudflare/_github/workflows/ci.yml +24 -0
  11. package/template-api/_targets/cloudflare/src/index.ts +17 -0
  12. package/template-api/_targets/node/src/server.ts +55 -0
  13. package/template-api/_targets/vercel/index.ts +16 -0
  14. package/template-api/_targets/vercel/vercel.json +4 -0
  15. package/template-api/src/app.ts +77 -0
  16. package/template-api/src/env.ts +4 -0
  17. package/template-api/tsconfig.json +2 -1
  18. package/template-api/tsconfig.test.json +1 -1
  19. package/template-full/README.md +155 -0
  20. package/template-full/_github/workflows/ci.yml +22 -0
  21. package/template-full/_gitignore +9 -0
  22. package/template-full/_mcp/test/mcp.test.ts +55 -0
  23. package/template-full/api/app.ts +132 -0
  24. package/template-full/api/db/index.ts +10 -0
  25. package/template-full/api/db/kv.ts +54 -0
  26. package/template-full/api/db/open.ts +33 -0
  27. package/template-full/api/db/schema.ts +57 -0
  28. package/template-full/api/env.ts +44 -0
  29. package/template-full/api/plans.ts +23 -0
  30. package/template-full/api/routes/account.ts +63 -0
  31. package/template-full/api/routes/auth.ts +134 -0
  32. package/template-full/api/routes/billing.ts +44 -0
  33. package/template-full/api/routes/notifications.ts +59 -0
  34. package/template-full/api/routes/privacy.ts +52 -0
  35. package/template-full/api/server.ts +44 -0
  36. package/template-full/api/services.ts +185 -0
  37. package/template-full/biome.json +50 -0
  38. package/template-full/drizzle/0000_init.sql +155 -0
  39. package/template-full/drizzle/0001_orgs.sql +47 -0
  40. package/template-full/drizzle/meta/0000_snapshot.json +974 -0
  41. package/template-full/drizzle/meta/0001_snapshot.json +1270 -0
  42. package/template-full/drizzle/meta/_journal.json +20 -0
  43. package/template-full/drizzle.config.ts +9 -0
  44. package/template-full/e2e/smoke.spec.ts +152 -0
  45. package/template-full/index.html +17 -0
  46. package/template-full/playwright.config.ts +10 -0
  47. package/template-full/scripts/dev.ts +17 -0
  48. package/template-full/src/app.css +9 -0
  49. package/template-full/src/components/toaster.tsx +13 -0
  50. package/template-full/src/lib/api.ts +40 -0
  51. package/template-full/src/main.tsx +36 -0
  52. package/template-full/src/routeTree.gen.ts +297 -0
  53. package/template-full/src/router.test.ts +23 -0
  54. package/template-full/src/router.ts +17 -0
  55. package/template-full/src/routes/__root.tsx +9 -0
  56. package/template-full/src/routes/_app/account.tsx +64 -0
  57. package/template-full/src/routes/_app/admin.tsx +38 -0
  58. package/template-full/src/routes/_app/billing.tsx +40 -0
  59. package/template-full/src/routes/_app/index.tsx +33 -0
  60. package/template-full/src/routes/_app/notifications.tsx +72 -0
  61. package/template-full/src/routes/_app/org/index.tsx +38 -0
  62. package/template-full/src/routes/_app/org/members.tsx +86 -0
  63. package/template-full/src/routes/_app/org/new.tsx +45 -0
  64. package/template-full/src/routes/_app/privacy.tsx +48 -0
  65. package/template-full/src/routes/_app.tsx +88 -0
  66. package/template-full/src/routes/invite.$token.tsx +55 -0
  67. package/template-full/src/routes/login.tsx +36 -0
  68. package/template-full/test/api.test.ts +189 -0
  69. package/template-full/tsconfig.api.json +19 -0
  70. package/template-full/tsconfig.app.json +26 -0
  71. package/template-full/tsconfig.json +9 -0
  72. package/template-full/tsconfig.node.json +16 -0
  73. package/template-full/tsconfig.test.json +8 -0
  74. package/template-full/vite.config.ts +24 -0
  75. package/template-api/src/index.ts +0 -55
  76. /package/template-api/{wrangler.jsonc → _targets/cloudflare/wrangler.jsonc} +0 -0
@@ -0,0 +1,20 @@
1
+ {
2
+ "version": "7",
3
+ "dialect": "sqlite",
4
+ "entries": [
5
+ {
6
+ "idx": 0,
7
+ "version": "6",
8
+ "when": 1794712191091,
9
+ "tag": "0000_init",
10
+ "breakpoints": true
11
+ },
12
+ {
13
+ "idx": 1,
14
+ "version": "6",
15
+ "when": 1794721249978,
16
+ "tag": "0001_orgs",
17
+ "breakpoints": true
18
+ }
19
+ ]
20
+ }
@@ -0,0 +1,9 @@
1
+ import { defineConfig } from "drizzle-kit"
2
+
3
+ // `db:generate` diffs api/db/schema.ts against drizzle/ and writes the next
4
+ // migration there. Commit it; the API applies pending ones on start.
5
+ export default defineConfig({
6
+ dialect: "sqlite",
7
+ schema: "./api/db/schema.ts",
8
+ out: "./drizzle",
9
+ })
@@ -0,0 +1,152 @@
1
+ import { type ChildProcess, spawn } from "node:child_process"
2
+ import { expect, test } from "@playwright/test"
3
+
4
+ // Sign in → admin → billing in a real browser against the built app, served by
5
+ // api/server.ts with a throwaway database and fake billing. The one-time code
6
+ // is read from the server's console, where development prints it. No keys.
7
+ const PORT = 4100 + Math.floor(Math.random() * 500)
8
+ const BASE = `http://localhost:${PORT}`
9
+ const PHONE = "+919000000001"
10
+ const PHONE_2 = "+919000000002"
11
+
12
+ let server: ChildProcess
13
+ let log = ""
14
+
15
+ test.beforeAll(async () => {
16
+ server = spawn("bun", ["api/server.ts"], {
17
+ env: {
18
+ ...process.env,
19
+ APP_ENV: "development",
20
+ PORT: String(PORT),
21
+ DATABASE_PATH: ":memory:",
22
+ SESSION_SECRET: "e2e-session-secret-0123456789abcdef",
23
+ OTP_SECRET: "e2e-otp-secret-0123456789abcdef01234",
24
+ ADMIN_PHONES: PHONE,
25
+ BILLING: "fake",
26
+ },
27
+ })
28
+ server.stdout?.on("data", (d) => {
29
+ log += String(d)
30
+ })
31
+ server.stderr?.on("data", (d) => {
32
+ log += String(d)
33
+ })
34
+ await expect
35
+ .poll(
36
+ () =>
37
+ fetch(`${BASE}/api/health`).then(
38
+ (r) => r.ok,
39
+ () => false,
40
+ ),
41
+ { timeout: 20_000 },
42
+ )
43
+ .toBe(true)
44
+ })
45
+
46
+ test.afterAll(() => {
47
+ server?.kill()
48
+ })
49
+
50
+ test("sign in, then admin, then billing", async ({ page }) => {
51
+ await page.goto(`${BASE}/`)
52
+ await expect(page).toHaveURL(/\/login$/)
53
+
54
+ await page.getByLabel(/phone/i).fill(PHONE)
55
+ await page.getByRole("button", { name: /send code/i }).click()
56
+ await expect.poll(() => /Your code is (\d+)/.exec(log)?.[1]).toBeTruthy()
57
+ const code = /Your code is (\d+)/.exec(log)?.[1] ?? ""
58
+ // A full code submits itself.
59
+ await page.getByRole("textbox", { name: "One-time code" }).fill(code)
60
+ await expect(page).toHaveURL(`${BASE}/`)
61
+ await expect(page.getByText(/You are on the/)).toBeVisible()
62
+
63
+ await page.getByRole("link", { name: "Admin" }).click()
64
+ // The admin panel loads the users table from /api/admin.
65
+ await expect(page.getByRole("heading", { name: "Users" })).toBeVisible()
66
+ await expect(page.getByRole("cell", { name: PHONE })).toBeVisible()
67
+
68
+ await page.getByRole("link", { name: "Billing" }).click()
69
+ // The plan picker marks the current plan, then checkout moves it.
70
+ const current = page.locator('[data-slot="plan-card"][data-current]')
71
+ await expect(current).toHaveAttribute("data-plan", "free")
72
+ await page.getByRole("button", { name: "Continue with Pro" }).click()
73
+ await expect(current).toHaveAttribute("data-plan", "pro")
74
+
75
+ await page.getByRole("link", { name: /inbox/i }).click()
76
+ await expect(page.getByText("Plan changed")).toBeVisible()
77
+
78
+ // The other wired screens render with data, not the error boundary.
79
+ await page.getByRole("link", { name: "Account" }).click()
80
+ await expect(page.getByText("This device")).toBeVisible()
81
+ await page.getByRole("link", { name: "Privacy" }).click()
82
+ await expect(page.getByText("Usage analytics")).toBeVisible()
83
+ })
84
+
85
+ /** Sign in on this page; reads the newest code the server printed. */
86
+ async function signIn(page: import("@playwright/test").Page, phone: string) {
87
+ const before = log.length
88
+ await page.getByLabel(/phone/i).fill(phone)
89
+ await page.getByRole("button", { name: /send code/i }).click()
90
+ await expect.poll(() => /Your code is (\d+)/.exec(log.slice(before))?.[1]).toBeTruthy()
91
+ const code = /Your code is (\d+)/.exec(log.slice(before))?.[1] ?? ""
92
+ await page.getByRole("textbox", { name: "One-time code" }).fill(code)
93
+ }
94
+
95
+ test("orgs: personal org, a second org, an invite, isolation", async ({ browser }) => {
96
+ const owner = await (await browser.newContext()).newPage()
97
+ await owner.goto(`${BASE}/login`)
98
+ await signIn(owner, PHONE)
99
+ await expect(owner).toHaveURL(`${BASE}/`)
100
+ const switcher = owner.getByRole("button", { name: "Switch organisation" })
101
+ await expect(switcher).toContainText("Personal")
102
+ const personalId = (
103
+ (await (await owner.request.get(`${BASE}/api/orgs/current`)).json()) as {
104
+ org: { id: string }
105
+ }
106
+ ).org.id
107
+
108
+ // A second org: made from the switcher, and the app moves into it.
109
+ await switcher.click()
110
+ await owner.getByRole("button", { name: "New organisation" }).click()
111
+ await owner.getByLabel("Name").fill("Second Org")
112
+ await owner.getByRole("button", { name: "Create" }).click()
113
+ await expect(owner).toHaveURL(`${BASE}/org`)
114
+ await expect(switcher).toContainText("Second Org")
115
+
116
+ // Invite by link.
117
+ await owner.getByRole("link", { name: "Members and invites" }).click()
118
+ await owner.getByRole("button", { name: "Invite", exact: true }).click()
119
+ await owner.getByRole("button", { name: "Create invite" }).click()
120
+ const link = await owner.getByLabel("Invite link").inputValue()
121
+ expect(link).toContain("/invite/")
122
+
123
+ // The second user opens it signed out, signs in, comes back and accepts.
124
+ const guest = await (await browser.newContext()).newPage()
125
+ await guest.goto(link)
126
+ await expect(guest.getByText("Second Org").first()).toBeVisible()
127
+ await guest.getByRole("button", { name: "Accept" }).click()
128
+ await expect(guest).toHaveURL(/\/login\?next=/)
129
+ await signIn(guest, PHONE_2)
130
+ await expect(guest).toHaveURL(link)
131
+ await guest.getByRole("button", { name: "Accept" }).click()
132
+ await expect(guest).toHaveURL(`${BASE}/`)
133
+ await expect(guest.getByRole("button", { name: "Switch organisation" })).toContainText(
134
+ "Second Org",
135
+ )
136
+
137
+ // They see the org they joined and their own, never the owner's personal org.
138
+ const theirs = (await (await guest.request.get(`${BASE}/api/orgs`)).json()) as {
139
+ orgs: { org: { id: string; name: string } }[]
140
+ }
141
+ expect(theirs.orgs.map((o) => o.org.name).sort()).toEqual(["Personal", "Second Org"])
142
+ expect(theirs.orgs.some((o) => o.org.id === personalId)).toBe(false)
143
+ await guest.getByRole("link", { name: "Org", exact: true }).click()
144
+ await guest.getByRole("link", { name: "Members and invites" }).click()
145
+ await expect(guest.locator('[data-slot="member"]')).toHaveCount(2)
146
+
147
+ // A request for the owner's personal org, by header: 404.
148
+ const other = await guest.request.get(`${BASE}/api/orgs/current/members`, {
149
+ headers: { "x-org": personalId },
150
+ })
151
+ expect(other.status()).toBe(404)
152
+ })
@@ -0,0 +1,17 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>__APP_NAME__</title>
7
+ <!-- Applies the stored theme before first paint. React mounts too late;
8
+ without this there is a visible flash of the wrong theme on load. -->
9
+ <script>
10
+ (() => { try { const t = localStorage.getItem("signet-theme"); const d = t === "dark" || ((!t || t === "system") && matchMedia("(prefers-color-scheme: dark)").matches); document.documentElement.classList.toggle("dark", d); document.documentElement.style.colorScheme = d ? "dark" : "light" } catch {} })()
11
+ </script>
12
+ </head>
13
+ <body>
14
+ <div id="root"></div>
15
+ <script type="module" src="/src/main.tsx"></script>
16
+ </body>
17
+ </html>
@@ -0,0 +1,10 @@
1
+ import { defineConfig } from "@playwright/test"
2
+
3
+ // The smoke test (e2e/smoke.spec.ts) starts its own API with a throwaway
4
+ // database and reads the one-time code from its console. Build first, then
5
+ // run test:e2e. Browsers, once: `playwright install chromium`.
6
+ export default defineConfig({
7
+ testDir: "e2e",
8
+ timeout: 60_000,
9
+ use: { headless: true },
10
+ })
@@ -0,0 +1,17 @@
1
+ /// <reference types="bun" />
2
+ // `dev`: the API (restarting on change) and Vite, which proxies /api to it.
3
+ // A script rather than `a & b` so it runs the same on Windows; when either
4
+ // stops, so does the other.
5
+ const bun = process.execPath
6
+ const procs = [
7
+ Bun.spawn([bun, "--watch", "api/server.ts"], { stdio: ["inherit", "inherit", "inherit"] }),
8
+ Bun.spawn([bun, "x", "vite"], { stdio: ["inherit", "inherit", "inherit"] }),
9
+ ]
10
+ const stop = () => {
11
+ for (const p of procs) p.kill()
12
+ }
13
+ process.on("SIGINT", stop)
14
+ process.on("SIGTERM", stop)
15
+ const code = await Promise.race(procs.map((p) => p.exited))
16
+ stop()
17
+ process.exit(code)
@@ -0,0 +1,9 @@
1
+ @import "tailwindcss";
2
+ @import "@dapplelight/signet-tokens/__THEME__.css";
3
+ @import "@dapplelight/signet-tokens/base.css";
4
+
5
+ /* Tailwind does not scan node_modules, and @dapplelight/signet-ui ships compiled JS
6
+ whose class names must be seen or every component renders unstyled. The theme
7
+ cannot declare this — a package does not know where it is installed.
8
+ Must come after the @import rules: CSS requires imports first. */
9
+ @source "../node_modules/@dapplelight/signet-ui/dist";
@@ -0,0 +1,13 @@
1
+ import { useTheme } from "@dapplelight/signet-ui/components/theme-provider"
2
+ import { Toaster as Sonner, type ToasterProps } from "sonner"
3
+
4
+ // sonner draws its own surface. These point it at the theme's popover tokens
5
+ // and follow the light/dark choice, so a toast reshapes with the theme like
6
+ // every other component. Call `toast()` from "sonner" anywhere.
7
+ const TOKENS =
8
+ "[--normal-bg:var(--color-popover)] [--normal-text:var(--color-popover-foreground)] [--normal-border:var(--color-border)] [--border-radius:var(--radius-lg)]"
9
+
10
+ export function Toaster(props: ToasterProps) {
11
+ const { resolvedTheme } = useTheme()
12
+ return <Sonner theme={resolvedTheme} className={TOKENS} {...props} />
13
+ }
@@ -0,0 +1,40 @@
1
+ import { createRpcClient } from "@dapplelight/signet-lib/api"
2
+ import { hc } from "hono/client"
3
+ // Types only: no server code reaches the browser bundle.
4
+ import type { AppType } from "../../api/app.ts"
5
+
6
+ /**
7
+ * The typed client for the API in api/. Paths, inputs and responses come from
8
+ * the server's routes, so a renamed route or field fails typecheck here.
9
+ * A 401 throws AuthError (main.tsx sends the user to /login), any other
10
+ * failure an ApiError with the envelope's message.
11
+ *
12
+ * const { user } = await (await api.account.me.$get()).json()
13
+ */
14
+ export const api = createRpcClient(hc<AppType>, { baseUrl: "/" }).api
15
+
16
+ /** The signed-in user and their plan; shared by the shell and the pages. */
17
+ export const meQuery = {
18
+ queryKey: ["me"],
19
+ queryFn: async () => (await api.account.me.$get()).json(),
20
+ }
21
+
22
+ /** The user's orgs with their role, for the switcher. */
23
+ export const orgsQuery = {
24
+ queryKey: ["orgs"],
25
+ queryFn: async () => (await api.orgs.$get()).json(),
26
+ }
27
+
28
+ /** The org this session is in (the switch cookie), with the caller's role, permissions and the roles on offer. */
29
+ export const currentOrgQuery = {
30
+ queryKey: ["orgs", "current"],
31
+ queryFn: async () => (await api.orgs.current.$get()).json(),
32
+ }
33
+
34
+ /** Switch org, then reload so no query from the old org survives. */
35
+ export async function switchOrg(orgId: string, to = "/") {
36
+ await api.orgs.switch.$post({ json: { orgId } })
37
+ window.location.assign(to)
38
+ }
39
+
40
+ export { ApiError, AuthError } from "@dapplelight/signet-lib/api"
@@ -0,0 +1,36 @@
1
+ import { onAuthErrorRedirect, queryDefaults } from "@dapplelight/signet-lib/api/query-client"
2
+ import { ThemeProvider } from "@dapplelight/signet-ui/components/theme-provider"
3
+ import { QueryClient, QueryClientProvider } from "@tanstack/react-query"
4
+ import { RouterProvider } from "@tanstack/react-router"
5
+ import { StrictMode } from "react"
6
+ import { createRoot } from "react-dom/client"
7
+ import { Toaster } from "./components/toaster"
8
+ import { createAppRouter } from "./router"
9
+ import "./app.css"
10
+
11
+ const queryClient = new QueryClient({ defaultOptions: queryDefaults() })
12
+ const router = createAppRouter()
13
+
14
+ // One redirect on session expiry, however many requests fail at once. A full
15
+ // page load, not router.navigate: it drops every cached query of the old
16
+ // session, and it re-arms this one-shot handler for the next session.
17
+ // buildLocation types "/login" against the route tree, so removing the route
18
+ // fails typecheck. In production the host must serve index.html for unknown
19
+ // paths (SPA fallback) or this reload 404s.
20
+ onAuthErrorRedirect(queryClient, () => {
21
+ window.location.assign(router.buildLocation({ to: "/login" }).href)
22
+ })
23
+
24
+ const rootElement = document.getElementById("root")
25
+ if (!rootElement) throw new Error("Root element #root not found in index.html")
26
+
27
+ createRoot(rootElement).render(
28
+ <StrictMode>
29
+ <ThemeProvider>
30
+ <QueryClientProvider client={queryClient}>
31
+ <RouterProvider router={router} />
32
+ <Toaster />
33
+ </QueryClientProvider>
34
+ </ThemeProvider>
35
+ </StrictMode>,
36
+ )
@@ -0,0 +1,297 @@
1
+ /* eslint-disable */
2
+
3
+ // @ts-nocheck
4
+
5
+ // noinspection JSUnusedGlobalSymbols
6
+
7
+ // This file was automatically generated by TanStack Router.
8
+ // You should NOT make any changes in this file as it will be overwritten.
9
+ // Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
10
+
11
+ import { Route as rootRouteImport } from "./routes/__root"
12
+ import { Route as AppRouteImport } from "./routes/_app"
13
+ import { Route as LoginRouteImport } from "./routes/login"
14
+ import { Route as AppIndexRouteImport } from "./routes/_app/index"
15
+ import { Route as AppAccountRouteImport } from "./routes/_app/account"
16
+ import { Route as AppAdminRouteImport } from "./routes/_app/admin"
17
+ import { Route as AppBillingRouteImport } from "./routes/_app/billing"
18
+ import { Route as AppNotificationsRouteImport } from "./routes/_app/notifications"
19
+ import { Route as AppPrivacyRouteImport } from "./routes/_app/privacy"
20
+ import { Route as InviteTokenRouteImport } from "./routes/invite.$token"
21
+ import { Route as AppOrgIndexRouteImport } from "./routes/_app/org/index"
22
+ import { Route as AppOrgMembersRouteImport } from "./routes/_app/org/members"
23
+ import { Route as AppOrgNewRouteImport } from "./routes/_app/org/new"
24
+
25
+ const AppRoute = AppRouteImport.update({
26
+ id: "/_app",
27
+ getParentRoute: () => rootRouteImport,
28
+ } as any)
29
+ const LoginRoute = LoginRouteImport.update({
30
+ id: "/login",
31
+ path: "/login",
32
+ getParentRoute: () => rootRouteImport,
33
+ } as any)
34
+ const AppIndexRoute = AppIndexRouteImport.update({
35
+ id: "/",
36
+ path: "/",
37
+ getParentRoute: () => AppRoute,
38
+ } as any)
39
+ const AppAccountRoute = AppAccountRouteImport.update({
40
+ id: "/account",
41
+ path: "/account",
42
+ getParentRoute: () => AppRoute,
43
+ } as any)
44
+ const AppAdminRoute = AppAdminRouteImport.update({
45
+ id: "/admin",
46
+ path: "/admin",
47
+ getParentRoute: () => AppRoute,
48
+ } as any)
49
+ const AppBillingRoute = AppBillingRouteImport.update({
50
+ id: "/billing",
51
+ path: "/billing",
52
+ getParentRoute: () => AppRoute,
53
+ } as any)
54
+ const AppNotificationsRoute = AppNotificationsRouteImport.update({
55
+ id: "/notifications",
56
+ path: "/notifications",
57
+ getParentRoute: () => AppRoute,
58
+ } as any)
59
+ const AppPrivacyRoute = AppPrivacyRouteImport.update({
60
+ id: "/privacy",
61
+ path: "/privacy",
62
+ getParentRoute: () => AppRoute,
63
+ } as any)
64
+ const InviteTokenRoute = InviteTokenRouteImport.update({
65
+ id: "/invite/$token",
66
+ path: "/invite/$token",
67
+ getParentRoute: () => rootRouteImport,
68
+ } as any)
69
+ const AppOrgIndexRoute = AppOrgIndexRouteImport.update({
70
+ id: "/org/",
71
+ path: "/org/",
72
+ getParentRoute: () => AppRoute,
73
+ } as any)
74
+ const AppOrgMembersRoute = AppOrgMembersRouteImport.update({
75
+ id: "/org/members",
76
+ path: "/org/members",
77
+ getParentRoute: () => AppRoute,
78
+ } as any)
79
+ const AppOrgNewRoute = AppOrgNewRouteImport.update({
80
+ id: "/org/new",
81
+ path: "/org/new",
82
+ getParentRoute: () => AppRoute,
83
+ } as any)
84
+
85
+ export interface FileRoutesByFullPath {
86
+ "/": typeof AppIndexRoute
87
+ "/login": typeof LoginRoute
88
+ "/account": typeof AppAccountRoute
89
+ "/admin": typeof AppAdminRoute
90
+ "/billing": typeof AppBillingRoute
91
+ "/notifications": typeof AppNotificationsRoute
92
+ "/privacy": typeof AppPrivacyRoute
93
+ "/invite/$token": typeof InviteTokenRoute
94
+ "/org/members": typeof AppOrgMembersRoute
95
+ "/org/new": typeof AppOrgNewRoute
96
+ "/org/": typeof AppOrgIndexRoute
97
+ }
98
+ export interface FileRoutesByTo {
99
+ "/login": typeof LoginRoute
100
+ "/account": typeof AppAccountRoute
101
+ "/admin": typeof AppAdminRoute
102
+ "/billing": typeof AppBillingRoute
103
+ "/notifications": typeof AppNotificationsRoute
104
+ "/privacy": typeof AppPrivacyRoute
105
+ "/invite/$token": typeof InviteTokenRoute
106
+ "/": typeof AppIndexRoute
107
+ "/org/members": typeof AppOrgMembersRoute
108
+ "/org/new": typeof AppOrgNewRoute
109
+ "/org": typeof AppOrgIndexRoute
110
+ }
111
+ export interface FileRoutesById {
112
+ __root__: typeof rootRouteImport
113
+ "/_app": typeof AppRouteWithChildren
114
+ "/login": typeof LoginRoute
115
+ "/_app/account": typeof AppAccountRoute
116
+ "/_app/admin": typeof AppAdminRoute
117
+ "/_app/billing": typeof AppBillingRoute
118
+ "/_app/notifications": typeof AppNotificationsRoute
119
+ "/_app/privacy": typeof AppPrivacyRoute
120
+ "/invite/$token": typeof InviteTokenRoute
121
+ "/_app/": typeof AppIndexRoute
122
+ "/_app/org/members": typeof AppOrgMembersRoute
123
+ "/_app/org/new": typeof AppOrgNewRoute
124
+ "/_app/org/": typeof AppOrgIndexRoute
125
+ }
126
+ export interface FileRouteTypes {
127
+ fileRoutesByFullPath: FileRoutesByFullPath
128
+ fullPaths:
129
+ | "/"
130
+ | "/login"
131
+ | "/account"
132
+ | "/admin"
133
+ | "/billing"
134
+ | "/notifications"
135
+ | "/privacy"
136
+ | "/invite/$token"
137
+ | "/org/members"
138
+ | "/org/new"
139
+ | "/org/"
140
+ fileRoutesByTo: FileRoutesByTo
141
+ to:
142
+ | "/login"
143
+ | "/account"
144
+ | "/admin"
145
+ | "/billing"
146
+ | "/notifications"
147
+ | "/privacy"
148
+ | "/invite/$token"
149
+ | "/"
150
+ | "/org/members"
151
+ | "/org/new"
152
+ | "/org"
153
+ id:
154
+ | "__root__"
155
+ | "/_app"
156
+ | "/login"
157
+ | "/_app/account"
158
+ | "/_app/admin"
159
+ | "/_app/billing"
160
+ | "/_app/notifications"
161
+ | "/_app/privacy"
162
+ | "/invite/$token"
163
+ | "/_app/"
164
+ | "/_app/org/members"
165
+ | "/_app/org/new"
166
+ | "/_app/org/"
167
+ fileRoutesById: FileRoutesById
168
+ }
169
+ export interface RootRouteChildren {
170
+ AppRoute: typeof AppRouteWithChildren
171
+ LoginRoute: typeof LoginRoute
172
+ InviteTokenRoute: typeof InviteTokenRoute
173
+ }
174
+
175
+ declare module "@tanstack/react-router" {
176
+ interface FileRoutesByPath {
177
+ "/_app": {
178
+ id: "/_app"
179
+ path: ""
180
+ fullPath: "/"
181
+ preLoaderRoute: typeof AppRouteImport
182
+ parentRoute: typeof rootRouteImport
183
+ }
184
+ "/login": {
185
+ id: "/login"
186
+ path: "/login"
187
+ fullPath: "/login"
188
+ preLoaderRoute: typeof LoginRouteImport
189
+ parentRoute: typeof rootRouteImport
190
+ }
191
+ "/_app/": {
192
+ id: "/_app/"
193
+ path: "/"
194
+ fullPath: "/"
195
+ preLoaderRoute: typeof AppIndexRouteImport
196
+ parentRoute: typeof AppRoute
197
+ }
198
+ "/_app/account": {
199
+ id: "/_app/account"
200
+ path: "/account"
201
+ fullPath: "/account"
202
+ preLoaderRoute: typeof AppAccountRouteImport
203
+ parentRoute: typeof AppRoute
204
+ }
205
+ "/_app/admin": {
206
+ id: "/_app/admin"
207
+ path: "/admin"
208
+ fullPath: "/admin"
209
+ preLoaderRoute: typeof AppAdminRouteImport
210
+ parentRoute: typeof AppRoute
211
+ }
212
+ "/_app/billing": {
213
+ id: "/_app/billing"
214
+ path: "/billing"
215
+ fullPath: "/billing"
216
+ preLoaderRoute: typeof AppBillingRouteImport
217
+ parentRoute: typeof AppRoute
218
+ }
219
+ "/_app/notifications": {
220
+ id: "/_app/notifications"
221
+ path: "/notifications"
222
+ fullPath: "/notifications"
223
+ preLoaderRoute: typeof AppNotificationsRouteImport
224
+ parentRoute: typeof AppRoute
225
+ }
226
+ "/_app/privacy": {
227
+ id: "/_app/privacy"
228
+ path: "/privacy"
229
+ fullPath: "/privacy"
230
+ preLoaderRoute: typeof AppPrivacyRouteImport
231
+ parentRoute: typeof AppRoute
232
+ }
233
+ "/invite/$token": {
234
+ id: "/invite/$token"
235
+ path: "/invite/$token"
236
+ fullPath: "/invite/$token"
237
+ preLoaderRoute: typeof InviteTokenRouteImport
238
+ parentRoute: typeof rootRouteImport
239
+ }
240
+ "/_app/org/": {
241
+ id: "/_app/org/"
242
+ path: "/org"
243
+ fullPath: "/org/"
244
+ preLoaderRoute: typeof AppOrgIndexRouteImport
245
+ parentRoute: typeof AppRoute
246
+ }
247
+ "/_app/org/members": {
248
+ id: "/_app/org/members"
249
+ path: "/org/members"
250
+ fullPath: "/org/members"
251
+ preLoaderRoute: typeof AppOrgMembersRouteImport
252
+ parentRoute: typeof AppRoute
253
+ }
254
+ "/_app/org/new": {
255
+ id: "/_app/org/new"
256
+ path: "/org/new"
257
+ fullPath: "/org/new"
258
+ preLoaderRoute: typeof AppOrgNewRouteImport
259
+ parentRoute: typeof AppRoute
260
+ }
261
+ }
262
+ }
263
+
264
+ interface AppRouteChildren {
265
+ AppAccountRoute: typeof AppAccountRoute
266
+ AppAdminRoute: typeof AppAdminRoute
267
+ AppBillingRoute: typeof AppBillingRoute
268
+ AppNotificationsRoute: typeof AppNotificationsRoute
269
+ AppPrivacyRoute: typeof AppPrivacyRoute
270
+ AppIndexRoute: typeof AppIndexRoute
271
+ AppOrgMembersRoute: typeof AppOrgMembersRoute
272
+ AppOrgNewRoute: typeof AppOrgNewRoute
273
+ AppOrgIndexRoute: typeof AppOrgIndexRoute
274
+ }
275
+
276
+ const AppRouteChildren: AppRouteChildren = {
277
+ AppAccountRoute: AppAccountRoute,
278
+ AppAdminRoute: AppAdminRoute,
279
+ AppBillingRoute: AppBillingRoute,
280
+ AppNotificationsRoute: AppNotificationsRoute,
281
+ AppPrivacyRoute: AppPrivacyRoute,
282
+ AppIndexRoute: AppIndexRoute,
283
+ AppOrgMembersRoute: AppOrgMembersRoute,
284
+ AppOrgNewRoute: AppOrgNewRoute,
285
+ AppOrgIndexRoute: AppOrgIndexRoute,
286
+ }
287
+
288
+ const AppRouteWithChildren = AppRoute._addFileChildren(AppRouteChildren)
289
+
290
+ const rootRouteChildren: RootRouteChildren = {
291
+ AppRoute: AppRouteWithChildren,
292
+ LoginRoute: LoginRoute,
293
+ InviteTokenRoute: InviteTokenRoute,
294
+ }
295
+ export const routeTree = rootRouteImport
296
+ ._addFileChildren(rootRouteChildren)
297
+ ._addFileTypes<FileRouteTypes>()
@@ -0,0 +1,23 @@
1
+ import { expect, test } from "bun:test"
2
+ import { createMemoryHistory } from "@tanstack/react-router"
3
+ import { createAppRouter } from "./router"
4
+
5
+ // Every page resolves to its own route. "/login" is where main.tsx sends a
6
+ // 401, so losing it would land users on a not-found page.
7
+ test.each([
8
+ ["/login", "/login"],
9
+ ["/", "/_app/"],
10
+ ["/account", "/_app/account"],
11
+ ["/notifications", "/_app/notifications"],
12
+ ["/privacy", "/_app/privacy"],
13
+ ["/billing", "/_app/billing"],
14
+ ["/admin", "/_app/admin"],
15
+ ["/org", "/_app/org/"],
16
+ ["/org/members", "/_app/org/members"],
17
+ ["/org/new", "/_app/org/new"],
18
+ ["/invite/abc", "/invite/$token"],
19
+ ])("%s resolves to %s", async (path, id) => {
20
+ const router = createAppRouter(createMemoryHistory({ initialEntries: [path] }))
21
+ await router.load()
22
+ expect(router.state.matches.at(-1)?.routeId).toBe(id as never)
23
+ })
@@ -0,0 +1,17 @@
1
+ import { createRouter, type RouterHistory } from "@tanstack/react-router"
2
+ import { routeTree } from "./routeTree.gen"
3
+
4
+ // routeTree.gen.ts is generated from src/routes by the router plugin in
5
+ // vite.config.ts on every `dev` and `build`. It is committed so `tsc` can
6
+ // typecheck before Vite has run; do not edit it by hand.
7
+
8
+ /** A history argument is for tests; the app uses the browser's. */
9
+ export function createAppRouter(history?: RouterHistory) {
10
+ return createRouter({ routeTree, history, defaultPreload: "intent" })
11
+ }
12
+
13
+ declare module "@tanstack/react-router" {
14
+ interface Register {
15
+ router: ReturnType<typeof createAppRouter>
16
+ }
17
+ }