create-croissant 0.1.55 → 0.1.56

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 (51) hide show
  1. package/dist/add.js +9 -9
  2. package/dist/index.js +8 -8
  3. package/package.json +1 -1
  4. package/template/README.md +0 -2
  5. package/template/apps/platform/package.json +0 -1
  6. package/template/package.json +0 -2
  7. package/template/pnpm-workspace.yaml +2 -2
  8. package/template/apps/desktop/.editorconfig +0 -9
  9. package/template/apps/desktop/.eslintcache +0 -1
  10. package/template/apps/desktop/.vscode/extensions.json +0 -3
  11. package/template/apps/desktop/.vscode/launch.json +0 -39
  12. package/template/apps/desktop/.vscode/settings.json +0 -11
  13. package/template/apps/desktop/README.md +0 -34
  14. package/template/apps/desktop/build/entitlements.mac.plist +0 -12
  15. package/template/apps/desktop/build/icon.icns +0 -0
  16. package/template/apps/desktop/build/icon.ico +0 -0
  17. package/template/apps/desktop/build/icon.png +0 -0
  18. package/template/apps/desktop/dev-app-update.yml +0 -3
  19. package/template/apps/desktop/electron-builder.yml +0 -45
  20. package/template/apps/desktop/electron.vite.config.ts +0 -26
  21. package/template/apps/desktop/package.json +0 -51
  22. package/template/apps/desktop/resources/icon.png +0 -0
  23. package/template/apps/desktop/src/main/index.ts +0 -88
  24. package/template/apps/desktop/src/preload/index.d.ts +0 -11
  25. package/template/apps/desktop/src/preload/index.ts +0 -29
  26. package/template/apps/desktop/src/renderer/index.html +0 -17
  27. package/template/apps/desktop/src/renderer/src/assets/base.css +0 -67
  28. package/template/apps/desktop/src/renderer/src/assets/electron.svg +0 -10
  29. package/template/apps/desktop/src/renderer/src/assets/main.css +0 -171
  30. package/template/apps/desktop/src/renderer/src/assets/wavy-lines.svg +0 -25
  31. package/template/apps/desktop/src/renderer/src/components/Versions.tsx +0 -15
  32. package/template/apps/desktop/src/renderer/src/components/app-sidebar.tsx +0 -182
  33. package/template/apps/desktop/src/renderer/src/components/login-form.tsx +0 -57
  34. package/template/apps/desktop/src/renderer/src/env.d.ts +0 -6
  35. package/template/apps/desktop/src/renderer/src/lib/auth-client.ts +0 -5
  36. package/template/apps/desktop/src/renderer/src/lib/orpc.ts +0 -12
  37. package/template/apps/desktop/src/renderer/src/main.tsx +0 -22
  38. package/template/apps/desktop/src/renderer/src/routeTree.gen.ts +0 -219
  39. package/template/apps/desktop/src/renderer/src/routes/__root.tsx +0 -48
  40. package/template/apps/desktop/src/renderer/src/routes/_auth/account.tsx +0 -267
  41. package/template/apps/desktop/src/renderer/src/routes/_auth/dashboard.tsx +0 -46
  42. package/template/apps/desktop/src/renderer/src/routes/_auth/examples/client-orpc-auth.tsx +0 -35
  43. package/template/apps/desktop/src/renderer/src/routes/_auth.tsx +0 -35
  44. package/template/apps/desktop/src/renderer/src/routes/_public/examples/client-orpc.tsx +0 -310
  45. package/template/apps/desktop/src/renderer/src/routes/_public/index.tsx +0 -54
  46. package/template/apps/desktop/src/renderer/src/routes/_public/login.tsx +0 -16
  47. package/template/apps/desktop/src/renderer/src/routes/_public.tsx +0 -23
  48. package/template/apps/desktop/tsconfig.json +0 -6
  49. package/template/apps/desktop/tsconfig.node.json +0 -8
  50. package/template/apps/desktop/tsconfig.web.json +0 -19
  51. package/template/apps/platform/src/lib/auth-client-electron.ts +0 -13
@@ -1,219 +0,0 @@
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 PublicRouteImport } from './routes/_public'
13
- import { Route as AuthRouteImport } from './routes/_auth'
14
- import { Route as PublicIndexRouteImport } from './routes/_public/index'
15
- import { Route as PublicLoginRouteImport } from './routes/_public/login'
16
- import { Route as AuthDashboardRouteImport } from './routes/_auth/dashboard'
17
- import { Route as AuthAccountRouteImport } from './routes/_auth/account'
18
- import { Route as PublicExamplesClientOrpcRouteImport } from './routes/_public/examples/client-orpc'
19
- import { Route as AuthExamplesClientOrpcAuthRouteImport } from './routes/_auth/examples/client-orpc-auth'
20
-
21
- const PublicRoute = PublicRouteImport.update({
22
- id: '/_public',
23
- getParentRoute: () => rootRouteImport,
24
- } as any)
25
- const AuthRoute = AuthRouteImport.update({
26
- id: '/_auth',
27
- getParentRoute: () => rootRouteImport,
28
- } as any)
29
- const PublicIndexRoute = PublicIndexRouteImport.update({
30
- id: '/',
31
- path: '/',
32
- getParentRoute: () => PublicRoute,
33
- } as any)
34
- const PublicLoginRoute = PublicLoginRouteImport.update({
35
- id: '/login',
36
- path: '/login',
37
- getParentRoute: () => PublicRoute,
38
- } as any)
39
- const AuthDashboardRoute = AuthDashboardRouteImport.update({
40
- id: '/dashboard',
41
- path: '/dashboard',
42
- getParentRoute: () => AuthRoute,
43
- } as any)
44
- const AuthAccountRoute = AuthAccountRouteImport.update({
45
- id: '/account',
46
- path: '/account',
47
- getParentRoute: () => AuthRoute,
48
- } as any)
49
- const PublicExamplesClientOrpcRoute =
50
- PublicExamplesClientOrpcRouteImport.update({
51
- id: '/examples/client-orpc',
52
- path: '/examples/client-orpc',
53
- getParentRoute: () => PublicRoute,
54
- } as any)
55
- const AuthExamplesClientOrpcAuthRoute =
56
- AuthExamplesClientOrpcAuthRouteImport.update({
57
- id: '/examples/client-orpc-auth',
58
- path: '/examples/client-orpc-auth',
59
- getParentRoute: () => AuthRoute,
60
- } as any)
61
-
62
- export interface FileRoutesByFullPath {
63
- '/': typeof PublicIndexRoute
64
- '/account': typeof AuthAccountRoute
65
- '/dashboard': typeof AuthDashboardRoute
66
- '/login': typeof PublicLoginRoute
67
- '/examples/client-orpc-auth': typeof AuthExamplesClientOrpcAuthRoute
68
- '/examples/client-orpc': typeof PublicExamplesClientOrpcRoute
69
- }
70
- export interface FileRoutesByTo {
71
- '/': typeof PublicIndexRoute
72
- '/account': typeof AuthAccountRoute
73
- '/dashboard': typeof AuthDashboardRoute
74
- '/login': typeof PublicLoginRoute
75
- '/examples/client-orpc-auth': typeof AuthExamplesClientOrpcAuthRoute
76
- '/examples/client-orpc': typeof PublicExamplesClientOrpcRoute
77
- }
78
- export interface FileRoutesById {
79
- __root__: typeof rootRouteImport
80
- '/_auth': typeof AuthRouteWithChildren
81
- '/_public': typeof PublicRouteWithChildren
82
- '/_auth/account': typeof AuthAccountRoute
83
- '/_auth/dashboard': typeof AuthDashboardRoute
84
- '/_public/login': typeof PublicLoginRoute
85
- '/_public/': typeof PublicIndexRoute
86
- '/_auth/examples/client-orpc-auth': typeof AuthExamplesClientOrpcAuthRoute
87
- '/_public/examples/client-orpc': typeof PublicExamplesClientOrpcRoute
88
- }
89
- export interface FileRouteTypes {
90
- fileRoutesByFullPath: FileRoutesByFullPath
91
- fullPaths:
92
- | '/'
93
- | '/account'
94
- | '/dashboard'
95
- | '/login'
96
- | '/examples/client-orpc-auth'
97
- | '/examples/client-orpc'
98
- fileRoutesByTo: FileRoutesByTo
99
- to:
100
- | '/'
101
- | '/account'
102
- | '/dashboard'
103
- | '/login'
104
- | '/examples/client-orpc-auth'
105
- | '/examples/client-orpc'
106
- id:
107
- | '__root__'
108
- | '/_auth'
109
- | '/_public'
110
- | '/_auth/account'
111
- | '/_auth/dashboard'
112
- | '/_public/login'
113
- | '/_public/'
114
- | '/_auth/examples/client-orpc-auth'
115
- | '/_public/examples/client-orpc'
116
- fileRoutesById: FileRoutesById
117
- }
118
- export interface RootRouteChildren {
119
- AuthRoute: typeof AuthRouteWithChildren
120
- PublicRoute: typeof PublicRouteWithChildren
121
- }
122
-
123
- declare module '@tanstack/react-router' {
124
- interface FileRoutesByPath {
125
- '/_public': {
126
- id: '/_public'
127
- path: ''
128
- fullPath: '/'
129
- preLoaderRoute: typeof PublicRouteImport
130
- parentRoute: typeof rootRouteImport
131
- }
132
- '/_auth': {
133
- id: '/_auth'
134
- path: ''
135
- fullPath: '/'
136
- preLoaderRoute: typeof AuthRouteImport
137
- parentRoute: typeof rootRouteImport
138
- }
139
- '/_public/': {
140
- id: '/_public/'
141
- path: '/'
142
- fullPath: '/'
143
- preLoaderRoute: typeof PublicIndexRouteImport
144
- parentRoute: typeof PublicRoute
145
- }
146
- '/_public/login': {
147
- id: '/_public/login'
148
- path: '/login'
149
- fullPath: '/login'
150
- preLoaderRoute: typeof PublicLoginRouteImport
151
- parentRoute: typeof PublicRoute
152
- }
153
- '/_auth/dashboard': {
154
- id: '/_auth/dashboard'
155
- path: '/dashboard'
156
- fullPath: '/dashboard'
157
- preLoaderRoute: typeof AuthDashboardRouteImport
158
- parentRoute: typeof AuthRoute
159
- }
160
- '/_auth/account': {
161
- id: '/_auth/account'
162
- path: '/account'
163
- fullPath: '/account'
164
- preLoaderRoute: typeof AuthAccountRouteImport
165
- parentRoute: typeof AuthRoute
166
- }
167
- '/_public/examples/client-orpc': {
168
- id: '/_public/examples/client-orpc'
169
- path: '/examples/client-orpc'
170
- fullPath: '/examples/client-orpc'
171
- preLoaderRoute: typeof PublicExamplesClientOrpcRouteImport
172
- parentRoute: typeof PublicRoute
173
- }
174
- '/_auth/examples/client-orpc-auth': {
175
- id: '/_auth/examples/client-orpc-auth'
176
- path: '/examples/client-orpc-auth'
177
- fullPath: '/examples/client-orpc-auth'
178
- preLoaderRoute: typeof AuthExamplesClientOrpcAuthRouteImport
179
- parentRoute: typeof AuthRoute
180
- }
181
- }
182
- }
183
-
184
- interface AuthRouteChildren {
185
- AuthAccountRoute: typeof AuthAccountRoute
186
- AuthDashboardRoute: typeof AuthDashboardRoute
187
- AuthExamplesClientOrpcAuthRoute: typeof AuthExamplesClientOrpcAuthRoute
188
- }
189
-
190
- const AuthRouteChildren: AuthRouteChildren = {
191
- AuthAccountRoute: AuthAccountRoute,
192
- AuthDashboardRoute: AuthDashboardRoute,
193
- AuthExamplesClientOrpcAuthRoute: AuthExamplesClientOrpcAuthRoute,
194
- }
195
-
196
- const AuthRouteWithChildren = AuthRoute._addFileChildren(AuthRouteChildren)
197
-
198
- interface PublicRouteChildren {
199
- PublicLoginRoute: typeof PublicLoginRoute
200
- PublicIndexRoute: typeof PublicIndexRoute
201
- PublicExamplesClientOrpcRoute: typeof PublicExamplesClientOrpcRoute
202
- }
203
-
204
- const PublicRouteChildren: PublicRouteChildren = {
205
- PublicLoginRoute: PublicLoginRoute,
206
- PublicIndexRoute: PublicIndexRoute,
207
- PublicExamplesClientOrpcRoute: PublicExamplesClientOrpcRoute,
208
- }
209
-
210
- const PublicRouteWithChildren =
211
- PublicRoute._addFileChildren(PublicRouteChildren)
212
-
213
- const rootRouteChildren: RootRouteChildren = {
214
- AuthRoute: AuthRouteWithChildren,
215
- PublicRoute: PublicRouteWithChildren,
216
- }
217
- export const routeTree = rootRouteImport
218
- ._addFileChildren(rootRouteChildren)
219
- ._addFileTypes<FileRouteTypes>()
@@ -1,48 +0,0 @@
1
- import { Link, Outlet, createRootRoute } from "@tanstack/react-router";
2
- import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
3
- import { Toaster } from "@workspace/ui/components/sonner";
4
- import { ThemeProvider } from "@workspace/ui/components/theme-provider";
5
- import { ORPCProvider } from "@workspace/orpc/react";
6
- import { orpc } from "@renderer/lib/orpc";
7
- import { TanStackRouterDevtools } from "@tanstack/react-router-devtools";
8
- import { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyTitle } from "@workspace/ui/components/empty";
9
- import { Button, buttonVariants } from "@workspace/ui/components/button";
10
-
11
- import "@workspace/ui/globals.css";
12
-
13
- const queryClient = new QueryClient();
14
-
15
- export const Route = createRootRoute({
16
- component: RootLayout,
17
- notFoundComponent: () => {
18
- return (
19
- <Empty className="h-screen border-none">
20
- <EmptyHeader>
21
- <EmptyTitle>404 - Page Not Found</EmptyTitle>
22
- <EmptyDescription>
23
- The page you are looking for does not exist or has been moved.
24
- </EmptyDescription>
25
- </EmptyHeader>
26
- <EmptyContent>
27
- <Link to="/" className={buttonVariants({ variant: "outline" })}>
28
- Go Home
29
- </Link>
30
- </EmptyContent>
31
- </Empty>
32
- );
33
- },
34
- });
35
-
36
- function RootLayout() {
37
- return (
38
- <ThemeProvider defaultTheme="system" storageKey="theme">
39
- <QueryClientProvider client={queryClient}>
40
- <ORPCProvider client={orpc}>
41
- <Outlet />
42
- <Toaster />
43
- <TanStackRouterDevtools />
44
- </ORPCProvider>
45
- </QueryClientProvider>
46
- </ThemeProvider>
47
- );
48
- }
@@ -1,267 +0,0 @@
1
- import * as React from "react";
2
- import { createFileRoute } from "@tanstack/react-router";
3
- import { useForm } from "@tanstack/react-form";
4
- import { z } from "zod";
5
- import { toast } from "sonner";
6
- import { Loader2, User } from "lucide-react";
7
-
8
- import { Button } from "@workspace/ui/components/button";
9
- import { Input } from "@workspace/ui/components/input";
10
- import {
11
- Card,
12
- CardContent,
13
- CardDescription,
14
- CardFooter,
15
- CardHeader,
16
- CardTitle,
17
- } from "@workspace/ui/components/card";
18
- import { Field, FieldError, FieldLabel } from "@workspace/ui/components/field";
19
- import { Avatar, AvatarFallback, AvatarImage } from "@workspace/ui/components/avatar";
20
- import { Separator } from "@workspace/ui/components/separator";
21
-
22
- import { authClient } from "@renderer/lib/auth-client";
23
-
24
- const profileSchema = z.object({
25
- name: z.string().min(1, "Name is required"),
26
- });
27
-
28
- const passwordSchema = z
29
- .object({
30
- currentPassword: z.string().min(1, "Current password is required"),
31
- newPassword: z.string().min(8, "New password must be at least 8 characters"),
32
- confirmPassword: z.string().min(1, "Confirm password is required"),
33
- })
34
- .refine((data) => data.newPassword === data.confirmPassword, {
35
- message: "Passwords do not match",
36
- path: ["confirmPassword"],
37
- });
38
-
39
- export const Route = createFileRoute("/_auth/account")({
40
- component: AccountPage,
41
- });
42
-
43
- function AccountPage() {
44
- const { data: sessionData, isPending } = authClient.useSession();
45
- const [loading, setLoading] = React.useState(false);
46
-
47
- const user = sessionData?.user;
48
-
49
- const profileForm = useForm({
50
- defaultValues: {
51
- name: user?.name || "",
52
- },
53
- validators: {
54
- onChange: profileSchema,
55
- },
56
- onSubmit: async ({ value }) => {
57
- setLoading(true);
58
- const { error } = await authClient.updateUser({
59
- name: value.name,
60
- });
61
-
62
- if (error) {
63
- toast.error(error.message || "Failed to update profile");
64
- } else {
65
- toast.success("Profile updated successfully");
66
- }
67
- setLoading(false);
68
- },
69
- });
70
-
71
- const passwordForm = useForm({
72
- defaultValues: {
73
- currentPassword: "",
74
- newPassword: "",
75
- confirmPassword: "",
76
- },
77
- validators: {
78
- onChange: passwordSchema,
79
- },
80
- onSubmit: async ({ value }) => {
81
- setLoading(true);
82
- const { error } = await authClient.changePassword({
83
- currentPassword: value.currentPassword,
84
- newPassword: value.newPassword,
85
- });
86
-
87
- if (error) {
88
- toast.error(error.message || "Failed to change password");
89
- } else {
90
- toast.success("Password changed successfully");
91
- passwordForm.reset();
92
- }
93
- setLoading(false);
94
- },
95
- });
96
-
97
- if (isPending) return <div>Loading...</div>;
98
- if (!user) return null;
99
-
100
- return (
101
- <div className="container max-w-4xl py-10">
102
- <div className="flex flex-col gap-8">
103
- <div>
104
- <h1 className="text-3xl font-bold">Account Settings</h1>
105
- <p className="text-muted-foreground">Manage your profile and account preferences.</p>
106
- </div>
107
-
108
- <Separator />
109
-
110
- <div className="grid gap-8">
111
- {/* Profile Section */}
112
- <Card>
113
- <CardHeader>
114
- <CardTitle>Profile</CardTitle>
115
- <CardDescription>Update your personal information.</CardDescription>
116
- </CardHeader>
117
- <CardContent className="space-y-6">
118
- <div className="flex items-center gap-4">
119
- <Avatar className="h-20 w-20">
120
- <AvatarImage src={user.image || ""} />
121
- <AvatarFallback className="text-2xl">
122
- {user.name.charAt(0) || <User className="h-10 w-10" />}
123
- </AvatarFallback>
124
- </Avatar>
125
- <div className="space-y-1">
126
- <p className="text-sm font-medium leading-none">{user.name}</p>
127
- <p className="text-sm text-muted-foreground">{user.email}</p>
128
- </div>
129
- </div>
130
-
131
- <form
132
- onSubmit={(e) => {
133
- e.preventDefault();
134
- e.stopPropagation();
135
- profileForm.handleSubmit();
136
- }}
137
- className="space-y-4"
138
- >
139
- <profileForm.Field
140
- name="name"
141
- children={(field) => (
142
- <Field>
143
- <FieldLabel htmlFor={field.name}>Display Name</FieldLabel>
144
- <Input
145
- id={field.name}
146
- value={field.state.value}
147
- onBlur={field.handleBlur}
148
- onChange={(e) => field.handleChange(e.target.value)}
149
- />
150
- <FieldError />
151
- </Field>
152
- )}
153
- />
154
- <Button type="submit" disabled={loading}>
155
- {loading && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
156
- Update Profile
157
- </Button>
158
- </form>
159
- </CardContent>
160
- </Card>
161
-
162
- {/* Password Section */}
163
- <Card>
164
- <CardHeader>
165
- <CardTitle>Security</CardTitle>
166
- <CardDescription>Change your password to keep your account secure.</CardDescription>
167
- </CardHeader>
168
- <CardContent>
169
- <form
170
- onSubmit={(e) => {
171
- e.preventDefault();
172
- e.stopPropagation();
173
- passwordForm.handleSubmit();
174
- }}
175
- className="space-y-4"
176
- >
177
- <passwordForm.Field
178
- name="currentPassword"
179
- children={(field) => (
180
- <Field>
181
- <FieldLabel htmlFor={field.name}>Current Password</FieldLabel>
182
- <Input
183
- id={field.name}
184
- type="password"
185
- value={field.state.value}
186
- onBlur={field.handleBlur}
187
- onChange={(e) => field.handleChange(e.target.value)}
188
- />
189
- <FieldError />
190
- </Field>
191
- )}
192
- />
193
- <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
194
- <passwordForm.Field
195
- name="newPassword"
196
- children={(field) => (
197
- <Field>
198
- <FieldLabel htmlFor={field.name}>New Password</FieldLabel>
199
- <Input
200
- id={field.name}
201
- type="password"
202
- value={field.state.value}
203
- onBlur={field.handleBlur}
204
- onChange={(e) => field.handleChange(e.target.value)}
205
- />
206
- <FieldError />
207
- </Field>
208
- )}
209
- />
210
- <passwordForm.Field
211
- name="confirmPassword"
212
- children={(field) => (
213
- <Field>
214
- <FieldLabel htmlFor={field.name}>Confirm New Password</FieldLabel>
215
- <Input
216
- id={field.name}
217
- type="password"
218
- value={field.state.value}
219
- onBlur={field.handleBlur}
220
- onChange={(e) => field.handleChange(e.target.value)}
221
- />
222
- <FieldError />
223
- </Field>
224
- )}
225
- />
226
- </div>
227
- <Button type="submit" variant="secondary" disabled={loading}>
228
- {loading && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
229
- Change Password
230
- </Button>
231
- </form>
232
- </CardContent>
233
- </Card>
234
-
235
- {/* Danger Zone */}
236
- <Card className="border-destructive/50">
237
- <CardHeader>
238
- <CardTitle className="text-destructive">Danger Zone</CardTitle>
239
- <CardDescription>Permanently delete your account and all data.</CardDescription>
240
- </CardHeader>
241
- <CardFooter>
242
- <Button
243
- variant="destructive"
244
- onClick={async () => {
245
- if (
246
- confirm(
247
- "Are you sure you want to delete your account? This action cannot be undone.",
248
- )
249
- ) {
250
- const { error } = await authClient.deleteUser();
251
- if (error) {
252
- toast.error(error.message || "Failed to delete account");
253
- } else {
254
- window.location.reload();
255
- }
256
- }
257
- }}
258
- >
259
- Delete Account
260
- </Button>
261
- </CardFooter>
262
- </Card>
263
- </div>
264
- </div>
265
- </div>
266
- );
267
- }
@@ -1,46 +0,0 @@
1
- import { createFileRoute } from "@tanstack/react-router";
2
- import { authClient } from "@renderer/lib/auth-client";
3
- import { useSecretData } from "@workspace/orpc/react";
4
-
5
- export const Route = createFileRoute("/_auth/dashboard")({
6
- component: Dashboard,
7
- });
8
-
9
- function Dashboard() {
10
- const { data: sessionData } = authClient.useSession();
11
- const user = sessionData?.user;
12
- const { data: secretData, isLoading, error } = useSecretData();
13
-
14
- if (!user) return null;
15
-
16
- return (
17
- <div className="flex min-h-svh p-6">
18
- <div className="flex max-w-md min-w-0 flex-col gap-4 text-sm leading-loose">
19
- <div>
20
- <h1 className="text-2xl font-bold">Dashboard</h1>
21
- <p>Welcome, {user.name}!</p>
22
- <p>This is a protected page. Only authenticated users can see this.</p>
23
-
24
- <div className="mt-6 rounded-lg border bg-gray-50 p-4 dark:bg-zinc-900">
25
- <h2 className="font-semibold mb-2">Secure oRPC Data:</h2>
26
- <p className="font-mono text-xs">
27
- {isLoading ? "Loading secret..." : error ? "Error: " + error.message : secretData?.secret}
28
- </p>
29
- </div>
30
-
31
- <div className="mt-4 flex gap-2">
32
- <button
33
- onClick={async () => {
34
- await authClient.signOut();
35
- window.location.reload();
36
- }}
37
- className="rounded bg-red-500 px-4 py-2 text-white hover:bg-red-600"
38
- >
39
- Sign Out
40
- </button>
41
- </div>
42
- </div>
43
- </div>
44
- </div>
45
- );
46
- }
@@ -1,35 +0,0 @@
1
- import { createFileRoute } from "@tanstack/react-router";
2
- import { useSecretData } from "@workspace/orpc/react";
3
- import { authClient } from "@renderer/lib/auth-client";
4
-
5
- export const Route = createFileRoute("/_auth/examples/client-orpc-auth")({
6
- component: ClientORPCAuth,
7
- });
8
-
9
- function ClientORPCAuth() {
10
- const { data: sessionData } = authClient.useSession();
11
- const session = sessionData;
12
-
13
- const { data, isLoading } = useSecretData();
14
-
15
- return (
16
- <div className="flex flex-col gap-4">
17
- <h1 className="text-2xl font-bold">Client + oRPC (Authenticated)</h1>
18
- <p>This page is protected and fetches secret data on the client using TanStack Query.</p>
19
-
20
- <div className="rounded-lg border p-4">
21
- <h2 className="font-semibold">User Session:</h2>
22
- <pre className="text-xs bg-muted p-2 rounded dark:bg-zinc-900 overflow-auto">{JSON.stringify(session, null, 2)}</pre>
23
- </div>
24
-
25
- <div className="rounded-lg border p-4">
26
- <h2 className="font-semibold">Secret Data (Client-side):</h2>
27
- {isLoading ? (
28
- <p>Loading...</p>
29
- ) : (
30
- <pre className="text-xs bg-muted p-2 rounded dark:bg-zinc-900 overflow-auto">{JSON.stringify(data, null, 2)}</pre>
31
- )}
32
- </div>
33
- </div>
34
- );
35
- }
@@ -1,35 +0,0 @@
1
- import { Outlet, createFileRoute, redirect } from "@tanstack/react-router";
2
- import { SidebarProvider, SidebarTrigger } from "@workspace/ui/components/sidebar";
3
- import { AuthSidebar } from "@renderer/components/app-sidebar";
4
- import { authClient } from "@renderer/lib/auth-client";
5
-
6
- export const Route = createFileRoute("/_auth")({
7
- beforeLoad: async ({ location }) => {
8
- const session = await authClient.getSession();
9
- if (!session.data) {
10
- throw redirect({
11
- to: "/login",
12
- search: {
13
- redirect: location.href,
14
- },
15
- });
16
- }
17
- },
18
- component: AuthLayout,
19
- });
20
-
21
- function AuthLayout() {
22
- return (
23
- <SidebarProvider>
24
- <AuthSidebar />
25
- <main className="flex flex-1 flex-col overflow-hidden">
26
- <header className="flex h-16 shrink-0 items-center gap-2 border-b px-4">
27
- <SidebarTrigger />
28
- </header>
29
- <div className="flex-1 overflow-auto p-4">
30
- <Outlet />
31
- </div>
32
- </main>
33
- </SidebarProvider>
34
- );
35
- }