create-better-t-stack 2.9.1 → 2.9.3
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.
- package/dist/index.js +3 -3
- package/package.json +3 -3
- package/templates/api/trpc/web/react/base/src/utils/trpc.ts.hbs +2 -5
- package/templates/examples/todo/web/react/next/src/app/todos/page.tsx.hbs +91 -8
- package/templates/examples/todo/web/react/react-router/src/routes/todos.tsx.hbs +0 -1
- package/templates/frontend/native/nativewind/app/(drawer)/index.tsx.hbs +28 -20
- package/templates/frontend/native/nativewind/app/_layout.tsx.hbs +17 -0
- package/templates/frontend/native/unistyles/app/(drawer)/index.tsx.hbs +31 -15
- package/templates/frontend/native/unistyles/app/_layout.tsx.hbs +24 -0
- package/templates/frontend/nuxt/app/pages/{index.vue → index.vue.hbs} +6 -1
- package/templates/frontend/react/next/src/app/page.tsx.hbs +19 -15
- package/templates/frontend/react/next/src/components/providers.tsx.hbs +34 -33
- package/templates/frontend/react/react-router/src/root.tsx.hbs +60 -44
- package/templates/frontend/react/react-router/src/routes/_index.tsx.hbs +21 -17
- package/templates/frontend/react/tanstack-router/src/main.tsx.hbs +26 -29
- package/templates/frontend/react/tanstack-router/src/routes/__root.tsx.hbs +14 -44
- package/templates/frontend/react/tanstack-router/src/routes/index.tsx.hbs +17 -14
- package/templates/frontend/react/tanstack-start/src/router.tsx.hbs +18 -17
- package/templates/frontend/react/tanstack-start/src/routes/__root.tsx.hbs +12 -2
- package/templates/frontend/react/tanstack-start/src/routes/index.tsx.hbs +21 -20
- package/templates/frontend/solid/src/main.tsx.hbs +6 -0
- package/templates/frontend/solid/src/routes/__root.tsx.hbs +14 -1
- package/templates/frontend/solid/src/routes/index.tsx.hbs +8 -1
- package/templates/frontend/svelte/src/routes/+layout.svelte.hbs +16 -5
- package/templates/frontend/svelte/src/routes/+page.svelte.hbs +4 -14
- /package/templates/frontend/nuxt/app/layouts/{default.vue → default.vue.hbs} +0 -0
- /package/templates/frontend/nuxt/app/plugins/{vue-query.ts → vue-query.ts.hbs} +0 -0
|
@@ -7,7 +7,9 @@ import { queryClient } from "@/utils/orpc";
|
|
|
7
7
|
{{#if (eq backend "convex")}}
|
|
8
8
|
import { ConvexProvider, ConvexReactClient } from "convex/react";
|
|
9
9
|
{{else}}
|
|
10
|
+
{{#unless (eq api "none")}}
|
|
10
11
|
import { QueryClientProvider } from "@tanstack/react-query";
|
|
12
|
+
{{/unless}}
|
|
11
13
|
{{/if}}
|
|
12
14
|
import { Stack } from "expo-router";
|
|
13
15
|
import { GestureHandlerRootView } from "react-native-gesture-handler";
|
|
@@ -51,6 +53,7 @@ export default function RootLayout() {
|
|
|
51
53
|
</GestureHandlerRootView>
|
|
52
54
|
</ConvexProvider>
|
|
53
55
|
{{else}}
|
|
56
|
+
{{#unless (eq api "none")}}
|
|
54
57
|
<QueryClientProvider client={queryClient}>
|
|
55
58
|
<GestureHandlerRootView style=\{{ flex: 1 }}>
|
|
56
59
|
<Stack
|
|
@@ -72,6 +75,27 @@ export default function RootLayout() {
|
|
|
72
75
|
</Stack>
|
|
73
76
|
</GestureHandlerRootView>
|
|
74
77
|
</QueryClientProvider>
|
|
78
|
+
{{else}}
|
|
79
|
+
<GestureHandlerRootView style=\{{ flex: 1 }}>
|
|
80
|
+
<Stack
|
|
81
|
+
screenOptions=\{{
|
|
82
|
+
headerStyle: {
|
|
83
|
+
backgroundColor: theme.colors.background,
|
|
84
|
+
},
|
|
85
|
+
headerTitleStyle: {
|
|
86
|
+
color: theme.colors.typography,
|
|
87
|
+
},
|
|
88
|
+
headerTintColor: theme.colors.typography,
|
|
89
|
+
}}
|
|
90
|
+
>
|
|
91
|
+
<Stack.Screen name="(drawer)" options=\{{ headerShown: false }} />
|
|
92
|
+
<Stack.Screen
|
|
93
|
+
name="modal"
|
|
94
|
+
options=\{{ title: "Modal", presentation: "modal" }}
|
|
95
|
+
/>
|
|
96
|
+
</Stack>
|
|
97
|
+
</GestureHandlerRootView>
|
|
98
|
+
{{/unless}}
|
|
75
99
|
{{/if}}
|
|
76
100
|
);
|
|
77
101
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
{{#unless (eq api "none")}}
|
|
2
3
|
const { $orpc } = useNuxtApp()
|
|
3
4
|
import { useQuery } from '@tanstack/vue-query'
|
|
5
|
+
{{/unless}}
|
|
4
6
|
|
|
5
7
|
const TITLE_TEXT = `
|
|
6
8
|
██████╗ ███████╗████████╗████████╗███████╗██████╗
|
|
@@ -18,14 +20,16 @@ const TITLE_TEXT = `
|
|
|
18
20
|
╚═╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝
|
|
19
21
|
`;
|
|
20
22
|
|
|
23
|
+
{{#unless (eq api "none")}}
|
|
21
24
|
const healthCheck = useQuery($orpc.healthCheck.queryOptions())
|
|
22
|
-
|
|
25
|
+
{{/unless}}
|
|
23
26
|
</script>
|
|
24
27
|
|
|
25
28
|
<template>
|
|
26
29
|
<div class="container mx-auto max-w-3xl px-4 py-2">
|
|
27
30
|
<pre class="overflow-x-auto font-mono text-sm whitespace-pre-wrap">{{ TITLE_TEXT }}</pre>
|
|
28
31
|
<div class="grid gap-6 mt-4">
|
|
32
|
+
{{#unless (eq api "none")}}
|
|
29
33
|
<section class="rounded-lg border p-4">
|
|
30
34
|
<h2 class="mb-2 font-medium">API Status</h2>
|
|
31
35
|
<div class="flex items-center gap-2">
|
|
@@ -58,6 +62,7 @@ const healthCheck = useQuery($orpc.healthCheck.queryOptions())
|
|
|
58
62
|
</div>
|
|
59
63
|
</div>
|
|
60
64
|
</section>
|
|
65
|
+
{{/unless}}
|
|
61
66
|
</div>
|
|
62
67
|
</div>
|
|
63
68
|
</template>
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
{{#if (eq backend "convex")}}
|
|
3
3
|
import { useQuery } from "convex/react";
|
|
4
4
|
import { api } from "@{{projectName}}/backend/convex/_generated/api.js";
|
|
5
|
-
{{else}}
|
|
5
|
+
{{else if (or (eq api "orpc") (eq api "trpc"))}}
|
|
6
|
+
import { useQuery } from "@tanstack/react-query";
|
|
6
7
|
{{#if (eq api "orpc")}}
|
|
7
8
|
import { orpc } from "@/utils/orpc";
|
|
8
9
|
{{/if}}
|
|
9
10
|
{{#if (eq api "trpc")}}
|
|
10
11
|
import { trpc } from "@/utils/trpc";
|
|
11
12
|
{{/if}}
|
|
12
|
-
import { useQuery } from "@tanstack/react-query";
|
|
13
13
|
{{/if}}
|
|
14
14
|
|
|
15
15
|
const TITLE_TEXT = `
|
|
@@ -43,8 +43,8 @@ export default function Home() {
|
|
|
43
43
|
<div className="grid gap-6">
|
|
44
44
|
<section className="rounded-lg border p-4">
|
|
45
45
|
<h2 className="mb-2 font-medium">API Status</h2>
|
|
46
|
+
{{#if (eq backend "convex")}}
|
|
46
47
|
<div className="flex items-center gap-2">
|
|
47
|
-
{{#if (eq backend "convex")}}
|
|
48
48
|
<div
|
|
49
49
|
className={`h-2 w-2 rounded-full ${healthCheck === "OK" ? "bg-green-500" : healthCheck === undefined ? "bg-orange-400" : "bg-red-500"}`}
|
|
50
50
|
/>
|
|
@@ -55,19 +55,23 @@ export default function Home() {
|
|
|
55
55
|
? "Connected"
|
|
56
56
|
: "Error"}
|
|
57
57
|
</span>
|
|
58
|
-
{{else}}
|
|
59
|
-
<div
|
|
60
|
-
className={`h-2 w-2 rounded-full ${healthCheck.data ? "bg-green-500" : "bg-red-500"}`}
|
|
61
|
-
/>
|
|
62
|
-
<span className="text-sm text-muted-foreground">
|
|
63
|
-
{healthCheck.isLoading
|
|
64
|
-
? "Checking..."
|
|
65
|
-
: healthCheck.data
|
|
66
|
-
? "Connected"
|
|
67
|
-
: "Disconnected"}
|
|
68
|
-
</span>
|
|
69
|
-
{{/if}}
|
|
70
58
|
</div>
|
|
59
|
+
{{else}}
|
|
60
|
+
{{#unless (eq api "none")}}
|
|
61
|
+
<div className="flex items-center gap-2">
|
|
62
|
+
<div
|
|
63
|
+
className={`h-2 w-2 rounded-full ${healthCheck.data ? "bg-green-500" : "bg-red-500"}`}
|
|
64
|
+
/>
|
|
65
|
+
<span className="text-sm text-muted-foreground">
|
|
66
|
+
{healthCheck.isLoading
|
|
67
|
+
? "Checking..."
|
|
68
|
+
: healthCheck.data
|
|
69
|
+
? "Connected"
|
|
70
|
+
: "Disconnected"}
|
|
71
|
+
</span>
|
|
72
|
+
</div>
|
|
73
|
+
{{/unless}}
|
|
74
|
+
{{/if}}
|
|
71
75
|
</section>
|
|
72
76
|
</div>
|
|
73
77
|
</div>
|
|
@@ -1,49 +1,50 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
{{#if (eq backend "convex")}}
|
|
3
|
-
import { ConvexProvider, ConvexReactClient } from "convex/react";
|
|
3
|
+
import { ConvexProvider, ConvexReactClient } from "convex/react";
|
|
4
4
|
{{else}}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
{{#unless (eq api "none")}}
|
|
6
|
+
import { QueryClientProvider } from "@tanstack/react-query";
|
|
7
|
+
{{#if (eq api "orpc")}}
|
|
8
|
+
import { orpc, ORPCContext, queryClient } from "@/utils/orpc";
|
|
9
|
+
{{/if}}
|
|
10
|
+
{{#if (eq api "trpc")}}
|
|
11
|
+
import { queryClient } from "@/utils/trpc";
|
|
12
|
+
{{/if}}
|
|
13
|
+
{{/unless}}
|
|
12
14
|
{{/if}}
|
|
13
15
|
import { ThemeProvider } from "./theme-provider";
|
|
14
16
|
import { Toaster } from "./ui/sonner";
|
|
15
17
|
|
|
16
18
|
{{#if (eq backend "convex")}}
|
|
17
|
-
const convex = new ConvexReactClient(process.env.NEXT_PUBLIC_CONVEX_URL!);
|
|
19
|
+
const convex = new ConvexReactClient(process.env.NEXT_PUBLIC_CONVEX_URL!);
|
|
18
20
|
{{/if}}
|
|
19
21
|
|
|
20
|
-
export default function Providers({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
{{#if (eq backend "convex")}}
|
|
33
|
-
<ConvexProvider client={convex}>{children}</ConvexProvider>
|
|
34
|
-
{{else}}
|
|
22
|
+
export default function Providers({ children, }: { children: React.ReactNode })
|
|
23
|
+
{ return (
|
|
24
|
+
<ThemeProvider
|
|
25
|
+
attribute="class"
|
|
26
|
+
defaultTheme="system"
|
|
27
|
+
enableSystem
|
|
28
|
+
disableTransitionOnChange
|
|
29
|
+
>
|
|
30
|
+
{{#if (eq backend "convex")}}
|
|
31
|
+
<ConvexProvider client={convex}>{children}</ConvexProvider>
|
|
32
|
+
{{else}}
|
|
33
|
+
{{#unless (eq api "none")}}
|
|
35
34
|
<QueryClientProvider client={queryClient}>
|
|
36
35
|
{{#if (eq api "orpc")}}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
<ORPCContext.Provider value={orpc}>
|
|
37
|
+
{children}
|
|
38
|
+
</ORPCContext.Provider>
|
|
40
39
|
{{/if}}
|
|
41
40
|
{{#if (eq api "trpc")}}
|
|
42
|
-
|
|
41
|
+
{children}
|
|
43
42
|
{{/if}}
|
|
44
43
|
</QueryClientProvider>
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
{{else}}
|
|
45
|
+
{children}
|
|
46
|
+
{{/unless}}
|
|
47
|
+
{{/if}}
|
|
48
|
+
<Toaster richColors />
|
|
49
|
+
</ThemeProvider>
|
|
50
|
+
) }
|
|
@@ -13,20 +13,25 @@ import { ThemeProvider } from "./components/theme-provider";
|
|
|
13
13
|
import { Toaster } from "./components/ui/sonner";
|
|
14
14
|
|
|
15
15
|
{{#if (eq backend "convex")}}
|
|
16
|
-
import { ConvexProvider, ConvexReactClient } from "convex/react";
|
|
16
|
+
import { ConvexProvider, ConvexReactClient } from "convex/react";
|
|
17
17
|
{{else}}
|
|
18
|
-
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
{{#unless (eq api "none")}}
|
|
19
|
+
import { QueryClientProvider } from "@tanstack/react-query";
|
|
20
|
+
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
|
21
|
+
{{#if (eq api "orpc")}}
|
|
22
|
+
import { orpc, ORPCContext, queryClient } from "./utils/orpc";
|
|
23
|
+
{{/if}}
|
|
24
|
+
{{#if (eq api "trpc")}}
|
|
25
|
+
import { queryClient } from "./utils/trpc";
|
|
26
|
+
{{/if}}
|
|
27
|
+
{{/unless}}
|
|
26
28
|
{{/if}}
|
|
27
29
|
|
|
28
30
|
export const links: Route.LinksFunction = () => [
|
|
29
|
-
{
|
|
31
|
+
{
|
|
32
|
+
rel: "preconnect",
|
|
33
|
+
href: "https://fonts.googleapis.com",
|
|
34
|
+
},
|
|
30
35
|
{
|
|
31
36
|
rel: "preconnect",
|
|
32
37
|
href: "https://fonts.gstatic.com",
|
|
@@ -57,28 +62,12 @@ export function Layout({ children }: { children: React.ReactNode }) {
|
|
|
57
62
|
}
|
|
58
63
|
|
|
59
64
|
{{#if (eq backend "convex")}}
|
|
60
|
-
export default function App() {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
<ConvexProvider client={convex}>
|
|
67
|
-
<ThemeProvider defaultTheme="dark" storageKey="vite-ui-theme">
|
|
68
|
-
<div className="grid grid-rows-[auto_1fr] h-svh">
|
|
69
|
-
<Header />
|
|
70
|
-
<Outlet />
|
|
71
|
-
</div>
|
|
72
|
-
<Toaster richColors />
|
|
73
|
-
</ThemeProvider>
|
|
74
|
-
</ConvexProvider>
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
{{else if (eq api "orpc")}}
|
|
78
|
-
export default function App() {
|
|
79
|
-
return (
|
|
80
|
-
<QueryClientProvider client={queryClient}>
|
|
81
|
-
<ORPCContext.Provider value={orpc}>
|
|
65
|
+
export default function App() {
|
|
66
|
+
const convex = new ConvexReactClient(
|
|
67
|
+
import.meta.env.VITE_CONVEX_URL as string,
|
|
68
|
+
);
|
|
69
|
+
return (
|
|
70
|
+
<ConvexProvider client={convex}>
|
|
82
71
|
<ThemeProvider defaultTheme="dark" storageKey="vite-ui-theme">
|
|
83
72
|
<div className="grid grid-rows-[auto_1fr] h-svh">
|
|
84
73
|
<Header />
|
|
@@ -86,15 +75,44 @@ export default function App() {
|
|
|
86
75
|
</div>
|
|
87
76
|
<Toaster richColors />
|
|
88
77
|
</ThemeProvider>
|
|
89
|
-
</
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
78
|
+
</ConvexProvider>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
{{else if (eq api "orpc")}}
|
|
82
|
+
export default function App() {
|
|
83
|
+
return (
|
|
84
|
+
<QueryClientProvider client={queryClient}>
|
|
85
|
+
<ORPCContext.Provider value={orpc}>
|
|
86
|
+
<ThemeProvider defaultTheme="dark" storageKey="vite-ui-theme">
|
|
87
|
+
<div className="grid grid-rows-[auto_1fr] h-svh">
|
|
88
|
+
<Header />
|
|
89
|
+
<Outlet />
|
|
90
|
+
</div>
|
|
91
|
+
<Toaster richColors />
|
|
92
|
+
</ThemeProvider>
|
|
93
|
+
</ORPCContext.Provider>
|
|
94
|
+
<ReactQueryDevtools position="bottom" buttonPosition="bottom-right" />
|
|
95
|
+
</QueryClientProvider>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
94
98
|
{{else if (eq api "trpc")}}
|
|
95
|
-
export default function App() {
|
|
96
|
-
|
|
97
|
-
|
|
99
|
+
export default function App() {
|
|
100
|
+
return (
|
|
101
|
+
<QueryClientProvider client={queryClient}>
|
|
102
|
+
<ThemeProvider defaultTheme="dark" storageKey="vite-ui-theme">
|
|
103
|
+
<div className="grid grid-rows-[auto_1fr] h-svh">
|
|
104
|
+
<Header />
|
|
105
|
+
<Outlet />
|
|
106
|
+
</div>
|
|
107
|
+
<Toaster richColors />
|
|
108
|
+
</ThemeProvider>
|
|
109
|
+
<ReactQueryDevtools position="bottom" buttonPosition="bottom-right" />
|
|
110
|
+
</QueryClientProvider>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
{{else}}
|
|
114
|
+
export default function App() {
|
|
115
|
+
return (
|
|
98
116
|
<ThemeProvider defaultTheme="dark" storageKey="vite-ui-theme">
|
|
99
117
|
<div className="grid grid-rows-[auto_1fr] h-svh">
|
|
100
118
|
<Header />
|
|
@@ -102,10 +120,8 @@ export default function App() {
|
|
|
102
120
|
</div>
|
|
103
121
|
<Toaster richColors />
|
|
104
122
|
</ThemeProvider>
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
);
|
|
108
|
-
}
|
|
123
|
+
);
|
|
124
|
+
}
|
|
109
125
|
{{/if}}
|
|
110
126
|
|
|
111
127
|
export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) {
|
|
@@ -2,14 +2,14 @@ import type { Route } from "./+types/_index";
|
|
|
2
2
|
{{#if (eq backend "convex")}}
|
|
3
3
|
import { useQuery } from "convex/react";
|
|
4
4
|
import { api } from "@{{projectName}}/backend/convex/_generated/api.js";
|
|
5
|
-
{{else}}
|
|
5
|
+
{{else if (or (eq api "orpc") (eq api "trpc"))}}
|
|
6
|
+
import { useQuery } from "@tanstack/react-query";
|
|
6
7
|
{{#if (eq api "orpc")}}
|
|
7
8
|
import { orpc } from "@/utils/orpc";
|
|
8
9
|
{{/if}}
|
|
9
10
|
{{#if (eq api "trpc")}}
|
|
10
11
|
import { trpc } from "@/utils/trpc";
|
|
11
12
|
{{/if}}
|
|
12
|
-
import { useQuery } from "@tanstack/react-query";
|
|
13
13
|
{{/if}}
|
|
14
14
|
|
|
15
15
|
const TITLE_TEXT = `
|
|
@@ -47,8 +47,8 @@ export default function Home() {
|
|
|
47
47
|
<div className="grid gap-6">
|
|
48
48
|
<section className="rounded-lg border p-4">
|
|
49
49
|
<h2 className="mb-2 font-medium">API Status</h2>
|
|
50
|
+
{{#if (eq backend "convex")}}
|
|
50
51
|
<div className="flex items-center gap-2">
|
|
51
|
-
{{#if (eq backend "convex")}}
|
|
52
52
|
<div
|
|
53
53
|
className={`h-2 w-2 rounded-full ${healthCheck === "OK" ? "bg-green-500" : healthCheck === undefined ? "bg-orange-400" : "bg-red-500"}`}
|
|
54
54
|
/>
|
|
@@ -59,21 +59,25 @@ export default function Home() {
|
|
|
59
59
|
? "Connected"
|
|
60
60
|
: "Error"}
|
|
61
61
|
</span>
|
|
62
|
-
{{else}}
|
|
63
|
-
<div
|
|
64
|
-
className={`h-2 w-2 rounded-full ${
|
|
65
|
-
healthCheck.data ? "bg-green-500" : "bg-red-500"
|
|
66
|
-
}`}
|
|
67
|
-
/>
|
|
68
|
-
<span className="text-sm text-muted-foreground">
|
|
69
|
-
{healthCheck.isLoading
|
|
70
|
-
? "Checking..."
|
|
71
|
-
: healthCheck.data
|
|
72
|
-
? "Connected"
|
|
73
|
-
: "Disconnected"}
|
|
74
|
-
</span>
|
|
75
|
-
{{/if}}
|
|
76
62
|
</div>
|
|
63
|
+
{{else}}
|
|
64
|
+
{{#unless (eq api "none")}}
|
|
65
|
+
<div className="flex items-center gap-2">
|
|
66
|
+
<div
|
|
67
|
+
className={`h-2 w-2 rounded-full ${
|
|
68
|
+
healthCheck.data ? "bg-green-500" : "bg-red-500"
|
|
69
|
+
}`}
|
|
70
|
+
/>
|
|
71
|
+
<span className="text-sm text-muted-foreground">
|
|
72
|
+
{healthCheck.isLoading
|
|
73
|
+
? "Checking..."
|
|
74
|
+
: healthCheck.data
|
|
75
|
+
? "Connected"
|
|
76
|
+
: "Disconnected"}
|
|
77
|
+
</span>
|
|
78
|
+
</div>
|
|
79
|
+
{{/unless}}
|
|
80
|
+
{{/if}}
|
|
77
81
|
</section>
|
|
78
82
|
</div>
|
|
79
83
|
</div>
|
|
@@ -2,57 +2,51 @@ import { RouterProvider, createRouter } from "@tanstack/react-router";
|
|
|
2
2
|
import ReactDOM from "react-dom/client";
|
|
3
3
|
import Loader from "./components/loader";
|
|
4
4
|
import { routeTree } from "./routeTree.gen";
|
|
5
|
+
|
|
5
6
|
{{#if (eq api "orpc")}}
|
|
6
|
-
import { QueryClientProvider } from "@tanstack/react-query";
|
|
7
|
-
import { orpc, queryClient } from "./utils/orpc";
|
|
7
|
+
import { QueryClientProvider } from "@tanstack/react-query";
|
|
8
|
+
import { orpc, queryClient } from "./utils/orpc";
|
|
8
9
|
{{/if}}
|
|
9
10
|
{{#if (eq api "trpc")}}
|
|
10
|
-
import { QueryClientProvider } from "@tanstack/react-query";
|
|
11
|
-
import { queryClient, trpc } from "./utils/trpc";
|
|
11
|
+
import { QueryClientProvider } from "@tanstack/react-query";
|
|
12
|
+
import { queryClient, trpc } from "./utils/trpc";
|
|
12
13
|
{{/if}}
|
|
13
14
|
{{#if (eq backend "convex")}}
|
|
14
|
-
import { ConvexProvider, ConvexReactClient } from "convex/react";
|
|
15
|
-
|
|
16
|
-
const convex = new ConvexReactClient(import.meta.env.VITE_CONVEX_URL as string);
|
|
15
|
+
import { ConvexProvider, ConvexReactClient } from "convex/react";
|
|
16
|
+
const convex = new ConvexReactClient(import.meta.env.VITE_CONVEX_URL as string);
|
|
17
17
|
{{/if}}
|
|
18
18
|
|
|
19
|
-
{{#if (eq api "orpc")}}
|
|
20
19
|
const router = createRouter({
|
|
21
20
|
routeTree,
|
|
22
21
|
defaultPreload: "intent",
|
|
23
22
|
defaultPendingComponent: () => <Loader />,
|
|
23
|
+
{{#if (eq api "orpc")}}
|
|
24
24
|
context: { orpc, queryClient },
|
|
25
|
-
Wrap: function WrapComponent({ children }) {
|
|
25
|
+
Wrap: function WrapComponent({ children }: { children: React.ReactNode }) {
|
|
26
26
|
return (
|
|
27
|
-
<QueryClientProvider client={queryClient}>
|
|
27
|
+
<QueryClientProvider client={queryClient}>
|
|
28
|
+
{children}
|
|
29
|
+
</QueryClientProvider>
|
|
28
30
|
);
|
|
29
31
|
},
|
|
30
|
-
}
|
|
31
|
-
{{/if}}
|
|
32
|
-
{{#if (eq api "trpc")}}
|
|
33
|
-
const router = createRouter({
|
|
34
|
-
routeTree,
|
|
35
|
-
defaultPreload: "intent",
|
|
36
|
-
defaultPendingComponent: () => <Loader />,
|
|
32
|
+
{{else if (eq api "trpc")}}
|
|
37
33
|
context: { trpc, queryClient },
|
|
38
|
-
Wrap: function WrapComponent({ children }) {
|
|
34
|
+
Wrap: function WrapComponent({ children }: { children: React.ReactNode }) {
|
|
39
35
|
return (
|
|
40
|
-
<QueryClientProvider client={queryClient}>
|
|
36
|
+
<QueryClientProvider client={queryClient}>
|
|
37
|
+
{children}
|
|
38
|
+
</QueryClientProvider>
|
|
41
39
|
);
|
|
42
40
|
},
|
|
43
|
-
}
|
|
44
|
-
{{/if}}
|
|
45
|
-
{{#if (eq backend "convex")}}
|
|
46
|
-
const router = createRouter({
|
|
47
|
-
routeTree,
|
|
48
|
-
defaultPreload: "intent",
|
|
49
|
-
defaultPendingComponent: () => <Loader />,
|
|
41
|
+
{{else if (eq backend "convex")}}
|
|
50
42
|
context: {},
|
|
51
|
-
Wrap: function WrapComponent({ children }) {
|
|
43
|
+
Wrap: function WrapComponent({ children }: { children: React.ReactNode }) {
|
|
52
44
|
return <ConvexProvider client={convex}>{children}</ConvexProvider>;
|
|
53
45
|
},
|
|
46
|
+
{{else}}
|
|
47
|
+
context: {},
|
|
48
|
+
{{/if}}
|
|
54
49
|
});
|
|
55
|
-
{{/if}}
|
|
56
50
|
|
|
57
51
|
declare module "@tanstack/react-router" {
|
|
58
52
|
interface Register {
|
|
@@ -61,7 +55,10 @@ declare module "@tanstack/react-router" {
|
|
|
61
55
|
}
|
|
62
56
|
|
|
63
57
|
const rootElement = document.getElementById("app");
|
|
64
|
-
|
|
58
|
+
|
|
59
|
+
if (!rootElement) {
|
|
60
|
+
throw new Error("Root element not found");
|
|
61
|
+
}
|
|
65
62
|
|
|
66
63
|
if (!rootElement.innerHTML) {
|
|
67
64
|
const root = ReactDOM.createRoot(rootElement);
|
|
@@ -31,14 +31,12 @@ export interface RouterAppContext {
|
|
|
31
31
|
orpc: typeof orpc;
|
|
32
32
|
queryClient: QueryClient;
|
|
33
33
|
}
|
|
34
|
-
{{
|
|
35
|
-
{{#if (eq api "trpc")}}
|
|
34
|
+
{{else if (eq api "trpc")}}
|
|
36
35
|
export interface RouterAppContext {
|
|
37
36
|
trpc: typeof trpc;
|
|
38
37
|
queryClient: QueryClient;
|
|
39
38
|
}
|
|
40
|
-
{{
|
|
41
|
-
{{#if (eq backend "convex")}}
|
|
39
|
+
{{else}}
|
|
42
40
|
export interface RouterAppContext {}
|
|
43
41
|
{{/if}}
|
|
44
42
|
|
|
@@ -63,18 +61,21 @@ export const Route = createRootRouteWithContext<RouterAppContext>()({
|
|
|
63
61
|
}),
|
|
64
62
|
});
|
|
65
63
|
|
|
66
|
-
{{#if (eq api "orpc")}}
|
|
67
64
|
function RootComponent() {
|
|
68
|
-
const [client] = useState<RouterClient<typeof appRouter>>(() => createORPCClient(link))
|
|
69
|
-
const [orpc] = useState(() => createORPCReactQueryUtils(client))
|
|
70
|
-
|
|
71
65
|
const isFetching = useRouterState({
|
|
72
66
|
select: (s) => s.isLoading,
|
|
73
67
|
});
|
|
68
|
+
|
|
69
|
+
{{#if (eq api "orpc")}}
|
|
70
|
+
const [client] = useState<RouterClient<typeof appRouter>>(() => createORPCClient(link));
|
|
71
|
+
const [orpcUtils] = useState(() => createORPCReactQueryUtils(client));
|
|
72
|
+
{{/if}}
|
|
73
|
+
|
|
74
74
|
return (
|
|
75
75
|
<>
|
|
76
76
|
<HeadContent />
|
|
77
|
-
|
|
77
|
+
{{#if (eq api "orpc")}}
|
|
78
|
+
<ORPCContext.Provider value={orpcUtils}>
|
|
78
79
|
<ThemeProvider defaultTheme="dark" storageKey="vite-ui-theme">
|
|
79
80
|
<div className="grid grid-rows-[auto_1fr] h-svh">
|
|
80
81
|
<Header />
|
|
@@ -83,20 +84,7 @@ function RootComponent() {
|
|
|
83
84
|
<Toaster richColors />
|
|
84
85
|
</ThemeProvider>
|
|
85
86
|
</ORPCContext.Provider>
|
|
86
|
-
|
|
87
|
-
<ReactQueryDevtools position="bottom" buttonPosition="bottom-right" />
|
|
88
|
-
</>
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
{{/if}}
|
|
92
|
-
{{#if (eq api "trpc")}}
|
|
93
|
-
function RootComponent() {
|
|
94
|
-
const isFetching = useRouterState({
|
|
95
|
-
select: (s) => s.isLoading,
|
|
96
|
-
});
|
|
97
|
-
return (
|
|
98
|
-
<>
|
|
99
|
-
<HeadContent />
|
|
87
|
+
{{else}}
|
|
100
88
|
<ThemeProvider defaultTheme="dark" storageKey="vite-ui-theme">
|
|
101
89
|
<div className="grid grid-rows-[auto_1fr] h-svh">
|
|
102
90
|
<Header />
|
|
@@ -104,29 +92,11 @@ function RootComponent() {
|
|
|
104
92
|
</div>
|
|
105
93
|
<Toaster richColors />
|
|
106
94
|
</ThemeProvider>
|
|
95
|
+
{{/if}}
|
|
107
96
|
<TanStackRouterDevtools position="bottom-left" />
|
|
97
|
+
{{#if (or (eq api "orpc") (eq api "trpc"))}}
|
|
108
98
|
<ReactQueryDevtools position="bottom" buttonPosition="bottom-right" />
|
|
99
|
+
{{/if}}
|
|
109
100
|
</>
|
|
110
101
|
);
|
|
111
102
|
}
|
|
112
|
-
{{/if}}
|
|
113
|
-
{{#if (eq backend "convex")}}
|
|
114
|
-
function RootComponent() {
|
|
115
|
-
const isFetching = useRouterState({
|
|
116
|
-
select: (s) => s.isLoading,
|
|
117
|
-
});
|
|
118
|
-
return (
|
|
119
|
-
<>
|
|
120
|
-
<HeadContent />
|
|
121
|
-
<ThemeProvider defaultTheme="dark" storageKey="vite-ui-theme">
|
|
122
|
-
<div className="grid grid-rows-[auto_1fr] h-svh">
|
|
123
|
-
<Header />
|
|
124
|
-
{isFetching ? <Loader /> : <Outlet />}
|
|
125
|
-
</div>
|
|
126
|
-
<Toaster richColors />
|
|
127
|
-
</ThemeProvider>
|
|
128
|
-
<TanStackRouterDevtools position="bottom-left" />
|
|
129
|
-
</>
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
{{/if}}
|
|
@@ -49,20 +49,8 @@ function HomeComponent() {
|
|
|
49
49
|
<div className="grid gap-6">
|
|
50
50
|
<section className="rounded-lg border p-4">
|
|
51
51
|
<h2 className="mb-2 font-medium">API Status</h2>
|
|
52
|
+
{{#if (eq backend "convex")}}
|
|
52
53
|
<div className="flex items-center gap-2">
|
|
53
|
-
{{#if (or (eq api "orpc") (eq api "trpc"))}}
|
|
54
|
-
<div
|
|
55
|
-
className={`h-2 w-2 rounded-full ${healthCheck.data ? "bg-green-500" : "bg-red-500"}`}
|
|
56
|
-
/>
|
|
57
|
-
<span className="text-sm text-muted-foreground">
|
|
58
|
-
{healthCheck.isLoading
|
|
59
|
-
? "Checking..."
|
|
60
|
-
: healthCheck.data
|
|
61
|
-
? "Connected"
|
|
62
|
-
: "Disconnected"}
|
|
63
|
-
</span>
|
|
64
|
-
{{/if}}
|
|
65
|
-
{{#if (eq backend "convex")}}
|
|
66
54
|
<div
|
|
67
55
|
className={`h-2 w-2 rounded-full ${healthCheck === "OK" ? "bg-green-500" : healthCheck === undefined ? "bg-orange-400" : "bg-red-500"}`}
|
|
68
56
|
/>
|
|
@@ -73,8 +61,23 @@ function HomeComponent() {
|
|
|
73
61
|
? "Connected"
|
|
74
62
|
: "Error"}
|
|
75
63
|
</span>
|
|
76
|
-
{{/if}}
|
|
77
64
|
</div>
|
|
65
|
+
{{else}}
|
|
66
|
+
{{#unless (eq api "none")}}
|
|
67
|
+
<div className="flex items-center gap-2">
|
|
68
|
+
<div
|
|
69
|
+
className={`h-2 w-2 rounded-full ${healthCheck.data ? "bg-green-500" : "bg-red-500"}`}
|
|
70
|
+
/>
|
|
71
|
+
<span className="text-sm text-muted-foreground">
|
|
72
|
+
{healthCheck.isLoading
|
|
73
|
+
? "Checking..."
|
|
74
|
+
: healthCheck.data
|
|
75
|
+
? "Connected"
|
|
76
|
+
: "Disconnected"}
|
|
77
|
+
</span>
|
|
78
|
+
</div>
|
|
79
|
+
{{/unless}}
|
|
80
|
+
{{/if}}
|
|
78
81
|
</section>
|
|
79
82
|
</div>
|
|
80
83
|
</div>
|