create-croissant 0.1.39 → 0.1.41
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 +5 -5
- package/package.json +7 -10
- package/template/.oxlintignore +11 -0
- package/template/README.md +6 -6
- package/template/apps/desktop/README.md +1 -1
- package/template/apps/desktop/electron-builder.yml +6 -6
- package/template/apps/desktop/electron.vite.config.ts +8 -8
- package/template/apps/desktop/package.json +4 -13
- package/template/apps/desktop/src/main/index.ts +32 -32
- package/template/apps/desktop/src/preload/index.d.ts +3 -3
- package/template/apps/desktop/src/preload/index.ts +8 -8
- package/template/apps/desktop/src/renderer/src/App.tsx +5 -5
- package/template/apps/desktop/src/renderer/src/assets/base.css +4 -4
- package/template/apps/desktop/src/renderer/src/assets/main.css +3 -3
- package/template/apps/desktop/src/renderer/src/components/Versions.tsx +4 -4
- package/template/apps/desktop/src/renderer/src/main.tsx +7 -7
- package/template/apps/desktop/tsconfig.json +1 -4
- package/template/apps/desktop/tsconfig.node.json +1 -1
- package/template/apps/desktop/tsconfig.web.json +4 -11
- package/template/apps/mobile/app/(tabs)/_layout.tsx +11 -10
- package/template/apps/mobile/app/(tabs)/explore.tsx +29 -27
- package/template/apps/mobile/app/(tabs)/index.tsx +25 -24
- package/template/apps/mobile/app/_layout.tsx +8 -8
- package/template/apps/mobile/app/modal.tsx +6 -6
- package/template/apps/mobile/components/external-link.tsx +5 -5
- package/template/apps/mobile/components/haptic-tab.tsx +4 -4
- package/template/apps/mobile/components/hello-wave.tsx +5 -4
- package/template/apps/mobile/components/parallax-scroll-view.tsx +15 -13
- package/template/apps/mobile/components/themed-text.tsx +14 -14
- package/template/apps/mobile/components/themed-view.tsx +3 -3
- package/template/apps/mobile/components/ui/collapsible.tsx +14 -13
- package/template/apps/mobile/components/ui/icon-symbol.ios.tsx +4 -4
- package/template/apps/mobile/components/ui/icon-symbol.tsx +9 -9
- package/template/apps/mobile/constants/theme.ts +19 -19
- package/template/apps/mobile/hooks/use-color-scheme.ts +1 -1
- package/template/apps/mobile/hooks/use-color-scheme.web.ts +3 -3
- package/template/apps/mobile/hooks/use-theme-color.ts +4 -4
- package/template/apps/mobile/package.json +3 -6
- package/template/apps/mobile/scripts/reset-project.js +2 -2
- package/template/apps/mobile/tsconfig.json +2 -9
- package/template/apps/platform/drizzle.config.ts +5 -5
- package/template/apps/platform/package.json +2 -6
- package/template/apps/platform/src/components/app-sidebar.tsx +60 -69
- package/template/apps/platform/src/components/login-form.tsx +32 -39
- package/template/apps/platform/src/components/search-form.tsx +5 -13
- package/template/apps/platform/src/components/signup-form.tsx +39 -49
- package/template/apps/platform/src/components/version-switcher.tsx +11 -21
- package/template/apps/platform/src/lib/auth-utils.ts +12 -14
- package/template/apps/platform/src/lib/orpc.ts +17 -17
- package/template/apps/platform/src/routeTree.gen.ts +264 -267
- package/template/apps/platform/src/router.tsx +5 -5
- package/template/apps/platform/src/routes/__root.tsx +13 -15
- package/template/apps/platform/src/routes/_auth/account.tsx +61 -50
- package/template/apps/platform/src/routes/_auth/dashboard.tsx +17 -17
- package/template/apps/platform/src/routes/_auth/examples/client-orpc-auth.tsx +13 -13
- package/template/apps/platform/src/routes/_auth/examples/ssr-orpc-auth.tsx +17 -17
- package/template/apps/platform/src/routes/_auth.tsx +5 -5
- package/template/apps/platform/src/routes/_public/examples/client-orpc.tsx +108 -88
- package/template/apps/platform/src/routes/_public/examples/isr.tsx +14 -14
- package/template/apps/platform/src/routes/_public/examples/ssr-orpc.tsx +92 -75
- package/template/apps/platform/src/routes/_public/index.tsx +22 -19
- package/template/apps/platform/src/routes/_public/login.tsx +4 -4
- package/template/apps/platform/src/routes/_public/signup.tsx +6 -5
- package/template/apps/platform/src/routes/_public.tsx +5 -5
- package/template/apps/platform/src/routes/api/auth/$.ts +13 -13
- package/template/apps/platform/src/routes/api/rpc.$.ts +13 -13
- package/template/apps/platform/tsconfig.json +1 -1
- package/template/apps/platform/vite.config.ts +8 -8
- package/template/docker-compose.yml +1 -1
- package/template/package.json +24 -22
- package/template/packages/auth/package.json +8 -12
- package/template/packages/auth/src/lib/auth.ts +1 -1
- package/template/packages/auth/tsconfig.json +1 -1
- package/template/packages/db/package.json +6 -10
- package/template/packages/db/src/index.ts +4 -4
- package/template/packages/db/src/schema.ts +2 -2
- package/template/packages/db/tsconfig.json +1 -1
- package/template/packages/orpc/package.json +6 -10
- package/template/packages/orpc/src/lib/planets.ts +39 -43
- package/template/packages/orpc/src/lib/router.ts +15 -15
- package/template/packages/orpc/tsconfig.json +1 -1
- package/template/packages/ui/package.json +8 -12
- package/template/packages/ui/src/components/accordion.tsx +20 -22
- package/template/packages/ui/src/components/alert-dialog.tsx +31 -56
- package/template/packages/ui/src/components/alert.tsx +15 -23
- package/template/packages/ui/src/components/aspect-ratio.tsx +3 -3
- package/template/packages/ui/src/components/avatar.tsx +19 -35
- package/template/packages/ui/src/components/badge.tsx +13 -17
- package/template/packages/ui/src/components/breadcrumb.tsx +22 -44
- package/template/packages/ui/src/components/button-group.tsx +16 -25
- package/template/packages/ui/src/components/button.tsx +8 -9
- package/template/packages/ui/src/components/calendar.tsx +43 -82
- package/template/packages/ui/src/components/card.tsx +15 -26
- package/template/packages/ui/src/components/carousel.tsx +70 -78
- package/template/packages/ui/src/components/chart.tsx +84 -117
- package/template/packages/ui/src/components/checkbox.tsx +8 -9
- package/template/packages/ui/src/components/collapsible.tsx +5 -9
- package/template/packages/ui/src/components/combobox.tsx +44 -68
- package/template/packages/ui/src/components/command.tsx +32 -47
- package/template/packages/ui/src/components/context-menu.tsx +45 -71
- package/template/packages/ui/src/components/dialog.tsx +29 -51
- package/template/packages/ui/src/components/direction.tsx +1 -4
- package/template/packages/ui/src/components/drawer.tsx +24 -38
- package/template/packages/ui/src/components/dropdown-menu.tsx +45 -55
- package/template/packages/ui/src/components/empty.tsx +16 -27
- package/template/packages/ui/src/components/field.tsx +49 -63
- package/template/packages/ui/src/components/hover-card.tsx +9 -14
- package/template/packages/ui/src/components/input-group.tsx +40 -52
- package/template/packages/ui/src/components/input-otp.tsx +17 -18
- package/template/packages/ui/src/components/input.tsx +6 -6
- package/template/packages/ui/src/components/item.tsx +31 -44
- package/template/packages/ui/src/components/kbd.tsx +5 -5
- package/template/packages/ui/src/components/label.tsx +6 -6
- package/template/packages/ui/src/components/menubar.tsx +51 -64
- package/template/packages/ui/src/components/mode-toggle.tsx +9 -15
- package/template/packages/ui/src/components/native-select.tsx +18 -24
- package/template/packages/ui/src/components/navigation-menu.tsx +28 -35
- package/template/packages/ui/src/components/pagination.tsx +19 -31
- package/template/packages/ui/src/components/popover.tsx +13 -26
- package/template/packages/ui/src/components/progress.tsx +13 -30
- package/template/packages/ui/src/components/radio-group.tsx +7 -7
- package/template/packages/ui/src/components/resizable.tsx +12 -20
- package/template/packages/ui/src/components/scroll-area.tsx +8 -12
- package/template/packages/ui/src/components/select.tsx +31 -42
- package/template/packages/ui/src/components/separator.tsx +6 -10
- package/template/packages/ui/src/components/sheet.tsx +25 -38
- package/template/packages/ui/src/components/sidebar.tsx +137 -170
- package/template/packages/ui/src/components/skeleton.tsx +3 -3
- package/template/packages/ui/src/components/slider.tsx +5 -5
- package/template/packages/ui/src/components/sonner.tsx +20 -24
- package/template/packages/ui/src/components/spinner.tsx +10 -5
- package/template/packages/ui/src/components/switch.tsx +6 -6
- package/template/packages/ui/src/components/table.tsx +18 -45
- package/template/packages/ui/src/components/tabs.tsx +14 -22
- package/template/packages/ui/src/components/textarea.tsx +5 -5
- package/template/packages/ui/src/components/theme-provider.tsx +43 -48
- package/template/packages/ui/src/components/toggle-group.tsx +18 -20
- package/template/packages/ui/src/components/toggle.tsx +9 -10
- package/template/packages/ui/src/components/tooltip.tsx +10 -22
- package/template/packages/ui/src/hooks/use-mobile.ts +11 -11
- package/template/packages/ui/src/lib/utils.ts +4 -4
- package/template/packages/ui/src/styles/globals.css +106 -106
- package/template/packages/ui/tsconfig.json +1 -1
- package/template/turbo.json +15 -6
- package/template/.prettierignore +0 -10
- package/template/apps/desktop/.prettierignore +0 -6
- package/template/apps/desktop/eslint.config.ts +0 -11
- package/template/apps/desktop/prettier.config.ts +0 -3
- package/template/apps/mobile/eslint.config.js +0 -10
- package/template/apps/platform/eslint.config.ts +0 -11
- package/template/apps/platform/prettier.config.ts +0 -3
- package/template/packages/auth/eslint.config.ts +0 -3
- package/template/packages/auth/prettier.config.ts +0 -3
- package/template/packages/config-eslint/index.ts +0 -24
- package/template/packages/config-eslint/package.json +0 -11
- package/template/packages/config-prettier/index.ts +0 -14
- package/template/packages/config-prettier/package.json +0 -7
- package/template/packages/db/eslint.config.ts +0 -3
- package/template/packages/db/prettier.config.ts +0 -3
- package/template/packages/orpc/eslint.config.ts +0 -3
- package/template/packages/orpc/prettier.config.ts +0 -3
- package/template/packages/ui/eslint.config.ts +0 -3
- package/template/packages/ui/prettier.config.ts +0 -3
- package/template/prettier.config.ts +0 -15
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { Button } from "@workspace/ui/components/button"
|
|
1
|
+
import { Button } from "@workspace/ui/components/button";
|
|
2
2
|
import {
|
|
3
3
|
Card,
|
|
4
4
|
CardContent,
|
|
5
5
|
CardDescription,
|
|
6
6
|
CardHeader,
|
|
7
7
|
CardTitle,
|
|
8
|
-
} from "@workspace/ui/components/card"
|
|
8
|
+
} from "@workspace/ui/components/card";
|
|
9
9
|
import {
|
|
10
10
|
Field,
|
|
11
11
|
FieldDescription,
|
|
12
12
|
FieldError,
|
|
13
13
|
FieldGroup,
|
|
14
14
|
FieldLabel,
|
|
15
|
-
} from "@workspace/ui/components/field"
|
|
16
|
-
import { Input } from "@workspace/ui/components/input"
|
|
17
|
-
import { useState } from "react"
|
|
18
|
-
import { Link } from "@tanstack/react-router"
|
|
19
|
-
import { useForm } from "@tanstack/react-form"
|
|
20
|
-
import { type } from "arktype"
|
|
21
|
-
import { authClient } from "@/lib/auth-client"
|
|
15
|
+
} from "@workspace/ui/components/field";
|
|
16
|
+
import { Input } from "@workspace/ui/components/input";
|
|
17
|
+
import { useState } from "react";
|
|
18
|
+
import { Link } from "@tanstack/react-router";
|
|
19
|
+
import { useForm } from "@tanstack/react-form";
|
|
20
|
+
import { type } from "arktype";
|
|
21
|
+
import { authClient } from "@/lib/auth-client";
|
|
22
22
|
|
|
23
23
|
const signupSchema = type({
|
|
24
24
|
name: "string>0",
|
|
@@ -30,15 +30,15 @@ const signupSchema = type({
|
|
|
30
30
|
ctx.error({
|
|
31
31
|
message: "Passwords do not match",
|
|
32
32
|
path: ["confirmPassword"],
|
|
33
|
-
})
|
|
34
|
-
return false
|
|
33
|
+
});
|
|
34
|
+
return false;
|
|
35
35
|
}
|
|
36
|
-
return true
|
|
37
|
-
})
|
|
36
|
+
return true;
|
|
37
|
+
});
|
|
38
38
|
|
|
39
39
|
export function SignupForm({ ...props }: React.ComponentProps<typeof Card>) {
|
|
40
|
-
const [loading, setLoading] = useState(false)
|
|
41
|
-
const [error, setError] = useState<string | null>(null)
|
|
40
|
+
const [loading, setLoading] = useState(false);
|
|
41
|
+
const [error, setError] = useState<string | null>(null);
|
|
42
42
|
|
|
43
43
|
const form = useForm({
|
|
44
44
|
defaultValues: {
|
|
@@ -51,47 +51,41 @@ export function SignupForm({ ...props }: React.ComponentProps<typeof Card>) {
|
|
|
51
51
|
onChange: signupSchema,
|
|
52
52
|
},
|
|
53
53
|
onSubmit: async ({ value }) => {
|
|
54
|
-
setLoading(true)
|
|
55
|
-
setError(null)
|
|
54
|
+
setLoading(true);
|
|
55
|
+
setError(null);
|
|
56
56
|
const { error: signUpError } = await authClient.signUp.email({
|
|
57
57
|
email: value.email,
|
|
58
58
|
password: value.password,
|
|
59
59
|
name: value.name,
|
|
60
60
|
callbackURL: "/dashboard",
|
|
61
|
-
})
|
|
61
|
+
});
|
|
62
62
|
if (signUpError) {
|
|
63
|
-
setError(signUpError.message || "Failed to sign up")
|
|
63
|
+
setError(signUpError.message || "Failed to sign up");
|
|
64
64
|
}
|
|
65
|
-
setLoading(false)
|
|
65
|
+
setLoading(false);
|
|
66
66
|
},
|
|
67
|
-
})
|
|
67
|
+
});
|
|
68
68
|
|
|
69
69
|
return (
|
|
70
70
|
<Card {...props}>
|
|
71
71
|
<CardHeader>
|
|
72
72
|
<CardTitle>Create an account</CardTitle>
|
|
73
|
-
<CardDescription>
|
|
74
|
-
Enter your information below to create your account
|
|
75
|
-
</CardDescription>
|
|
73
|
+
<CardDescription>Enter your information below to create your account</CardDescription>
|
|
76
74
|
</CardHeader>
|
|
77
75
|
<CardContent>
|
|
78
76
|
<form
|
|
79
77
|
onSubmit={(e) => {
|
|
80
|
-
e.preventDefault()
|
|
81
|
-
e.stopPropagation()
|
|
82
|
-
form.handleSubmit()
|
|
78
|
+
e.preventDefault();
|
|
79
|
+
e.stopPropagation();
|
|
80
|
+
form.handleSubmit();
|
|
83
81
|
}}
|
|
84
82
|
>
|
|
85
83
|
<FieldGroup>
|
|
86
|
-
{error &&
|
|
87
|
-
<div className="rounded bg-red-100 p-2 text-sm text-red-600">
|
|
88
|
-
{error}
|
|
89
|
-
</div>
|
|
90
|
-
)}
|
|
84
|
+
{error && <div className="rounded bg-red-100 p-2 text-sm text-red-600">{error}</div>}
|
|
91
85
|
<form.Field
|
|
92
86
|
name="name"
|
|
93
87
|
children={(field) => {
|
|
94
|
-
const isInvalid = field.state.meta.isTouched && field.state.meta.errors.length > 0
|
|
88
|
+
const isInvalid = field.state.meta.isTouched && field.state.meta.errors.length > 0;
|
|
95
89
|
return (
|
|
96
90
|
<Field data-invalid={isInvalid}>
|
|
97
91
|
<FieldLabel htmlFor={field.name}>Full Name</FieldLabel>
|
|
@@ -107,13 +101,13 @@ export function SignupForm({ ...props }: React.ComponentProps<typeof Card>) {
|
|
|
107
101
|
/>
|
|
108
102
|
{isInvalid && <FieldError errors={field.state.meta.errors} />}
|
|
109
103
|
</Field>
|
|
110
|
-
)
|
|
104
|
+
);
|
|
111
105
|
}}
|
|
112
106
|
/>
|
|
113
107
|
<form.Field
|
|
114
108
|
name="email"
|
|
115
109
|
children={(field) => {
|
|
116
|
-
const isInvalid = field.state.meta.isTouched && field.state.meta.errors.length > 0
|
|
110
|
+
const isInvalid = field.state.meta.isTouched && field.state.meta.errors.length > 0;
|
|
117
111
|
return (
|
|
118
112
|
<Field data-invalid={isInvalid}>
|
|
119
113
|
<FieldLabel htmlFor={field.name}>Email</FieldLabel>
|
|
@@ -128,18 +122,18 @@ export function SignupForm({ ...props }: React.ComponentProps<typeof Card>) {
|
|
|
128
122
|
required
|
|
129
123
|
/>
|
|
130
124
|
<FieldDescription>
|
|
131
|
-
We'll use this to contact you. We will not share your email
|
|
132
|
-
|
|
125
|
+
We'll use this to contact you. We will not share your email with anyone
|
|
126
|
+
else.
|
|
133
127
|
</FieldDescription>
|
|
134
128
|
{isInvalid && <FieldError errors={field.state.meta.errors} />}
|
|
135
129
|
</Field>
|
|
136
|
-
)
|
|
130
|
+
);
|
|
137
131
|
}}
|
|
138
132
|
/>
|
|
139
133
|
<form.Field
|
|
140
134
|
name="password"
|
|
141
135
|
children={(field) => {
|
|
142
|
-
const isInvalid = field.state.meta.isTouched && field.state.meta.errors.length > 0
|
|
136
|
+
const isInvalid = field.state.meta.isTouched && field.state.meta.errors.length > 0;
|
|
143
137
|
return (
|
|
144
138
|
<Field data-invalid={isInvalid}>
|
|
145
139
|
<FieldLabel htmlFor={field.name}>Password</FieldLabel>
|
|
@@ -152,23 +146,19 @@ export function SignupForm({ ...props }: React.ComponentProps<typeof Card>) {
|
|
|
152
146
|
onChange={(e) => field.handleChange(e.target.value)}
|
|
153
147
|
required
|
|
154
148
|
/>
|
|
155
|
-
<FieldDescription>
|
|
156
|
-
Must be at least 8 characters long.
|
|
157
|
-
</FieldDescription>
|
|
149
|
+
<FieldDescription>Must be at least 8 characters long.</FieldDescription>
|
|
158
150
|
{isInvalid && <FieldError errors={field.state.meta.errors} />}
|
|
159
151
|
</Field>
|
|
160
|
-
)
|
|
152
|
+
);
|
|
161
153
|
}}
|
|
162
154
|
/>
|
|
163
155
|
<form.Field
|
|
164
156
|
name="confirmPassword"
|
|
165
157
|
children={(field) => {
|
|
166
|
-
const isInvalid = field.state.meta.isTouched && field.state.meta.errors.length > 0
|
|
158
|
+
const isInvalid = field.state.meta.isTouched && field.state.meta.errors.length > 0;
|
|
167
159
|
return (
|
|
168
160
|
<Field data-invalid={isInvalid}>
|
|
169
|
-
<FieldLabel htmlFor={field.name}>
|
|
170
|
-
Confirm Password
|
|
171
|
-
</FieldLabel>
|
|
161
|
+
<FieldLabel htmlFor={field.name}>Confirm Password</FieldLabel>
|
|
172
162
|
<Input
|
|
173
163
|
id={field.name}
|
|
174
164
|
name={field.name}
|
|
@@ -181,7 +171,7 @@ export function SignupForm({ ...props }: React.ComponentProps<typeof Card>) {
|
|
|
181
171
|
<FieldDescription>Please confirm your password.</FieldDescription>
|
|
182
172
|
{isInvalid && <FieldError errors={field.state.meta.errors} />}
|
|
183
173
|
</Field>
|
|
184
|
-
)
|
|
174
|
+
);
|
|
185
175
|
}}
|
|
186
176
|
/>
|
|
187
177
|
<FieldGroup>
|
|
@@ -209,5 +199,5 @@ export function SignupForm({ ...props }: React.ComponentProps<typeof Card>) {
|
|
|
209
199
|
</form>
|
|
210
200
|
</CardContent>
|
|
211
201
|
</Card>
|
|
212
|
-
)
|
|
202
|
+
);
|
|
213
203
|
}
|
|
@@ -1,28 +1,24 @@
|
|
|
1
|
-
"use client"
|
|
1
|
+
"use client";
|
|
2
2
|
|
|
3
|
-
import * as React from "react"
|
|
3
|
+
import * as React from "react";
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
DropdownMenu,
|
|
7
7
|
DropdownMenuContent,
|
|
8
8
|
DropdownMenuItem,
|
|
9
9
|
DropdownMenuTrigger,
|
|
10
|
-
} from "@workspace/ui/components/dropdown-menu"
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
SidebarMenuButton,
|
|
14
|
-
SidebarMenuItem,
|
|
15
|
-
} from "@workspace/ui/components/sidebar"
|
|
16
|
-
import { CheckIcon, ChevronsUpDownIcon, GalleryVerticalEndIcon } from "lucide-react"
|
|
10
|
+
} from "@workspace/ui/components/dropdown-menu";
|
|
11
|
+
import { SidebarMenu, SidebarMenuButton, SidebarMenuItem } from "@workspace/ui/components/sidebar";
|
|
12
|
+
import { CheckIcon, ChevronsUpDownIcon, GalleryVerticalEndIcon } from "lucide-react";
|
|
17
13
|
|
|
18
14
|
export function VersionSwitcher({
|
|
19
15
|
versions,
|
|
20
16
|
defaultVersion,
|
|
21
17
|
}: {
|
|
22
|
-
versions: Array<string
|
|
23
|
-
defaultVersion: string
|
|
18
|
+
versions: Array<string>;
|
|
19
|
+
defaultVersion: string;
|
|
24
20
|
}) {
|
|
25
|
-
const [selectedVersion, setSelectedVersion] = React.useState(defaultVersion)
|
|
21
|
+
const [selectedVersion, setSelectedVersion] = React.useState(defaultVersion);
|
|
26
22
|
return (
|
|
27
23
|
<SidebarMenu>
|
|
28
24
|
<SidebarMenuItem>
|
|
@@ -46,19 +42,13 @@ export function VersionSwitcher({
|
|
|
46
42
|
</DropdownMenuTrigger>
|
|
47
43
|
<DropdownMenuContent align="start">
|
|
48
44
|
{versions.map((version) => (
|
|
49
|
-
<DropdownMenuItem
|
|
50
|
-
|
|
51
|
-
onSelect={() => setSelectedVersion(version)}
|
|
52
|
-
>
|
|
53
|
-
v{version}{" "}
|
|
54
|
-
{version === selectedVersion && (
|
|
55
|
-
<CheckIcon className="ml-auto" />
|
|
56
|
-
)}
|
|
45
|
+
<DropdownMenuItem key={version} onSelect={() => setSelectedVersion(version)}>
|
|
46
|
+
v{version} {version === selectedVersion && <CheckIcon className="ml-auto" />}
|
|
57
47
|
</DropdownMenuItem>
|
|
58
48
|
))}
|
|
59
49
|
</DropdownMenuContent>
|
|
60
50
|
</DropdownMenu>
|
|
61
51
|
</SidebarMenuItem>
|
|
62
52
|
</SidebarMenu>
|
|
63
|
-
)
|
|
53
|
+
);
|
|
64
54
|
}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import { createServerFn } from "@tanstack/react-start"
|
|
2
|
-
import { getRequest } from "@tanstack/react-start/server"
|
|
3
|
-
import { auth } from "@workspace/auth/lib/auth"
|
|
1
|
+
import { createServerFn } from "@tanstack/react-start";
|
|
2
|
+
import { getRequest } from "@tanstack/react-start/server";
|
|
3
|
+
import { auth } from "@workspace/auth/lib/auth";
|
|
4
4
|
|
|
5
|
-
export const getSessionFn = createServerFn({ method: "GET" }).handler(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
)
|
|
5
|
+
export const getSessionFn = createServerFn({ method: "GET" }).handler(async () => {
|
|
6
|
+
const request = getRequest();
|
|
7
|
+
|
|
8
|
+
const session = await auth.api.getSession({
|
|
9
|
+
headers: request.headers,
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
return session;
|
|
13
|
+
});
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { createORPCClient } from
|
|
2
|
-
import { RPCLink } from
|
|
3
|
-
import { createIsomorphicFn } from
|
|
4
|
-
import { getRequestHeaders } from
|
|
5
|
-
import { createRouterClient } from
|
|
6
|
-
import { router } from
|
|
7
|
-
import { auth } from
|
|
8
|
-
import type { RouterClient } from
|
|
1
|
+
import { createORPCClient } from "@orpc/client";
|
|
2
|
+
import { RPCLink } from "@orpc/client/fetch";
|
|
3
|
+
import { createIsomorphicFn } from "@tanstack/react-start";
|
|
4
|
+
import { getRequestHeaders } from "@tanstack/react-start/server";
|
|
5
|
+
import { createRouterClient } from "@orpc/server";
|
|
6
|
+
import { router } from "@workspace/orpc/router";
|
|
7
|
+
import { auth } from "@workspace/auth/lib/auth";
|
|
8
|
+
import type { RouterClient } from "@orpc/server";
|
|
9
9
|
|
|
10
10
|
const getORPCClient = createIsomorphicFn()
|
|
11
|
-
.server(() =>
|
|
11
|
+
.server(() =>
|
|
12
12
|
createRouterClient(router, {
|
|
13
13
|
context: async () => {
|
|
14
|
-
const headers = getRequestHeaders()
|
|
14
|
+
const headers = getRequestHeaders();
|
|
15
15
|
const session = await auth.api.getSession({
|
|
16
16
|
headers,
|
|
17
|
-
})
|
|
17
|
+
});
|
|
18
18
|
return {
|
|
19
19
|
session,
|
|
20
|
-
}
|
|
20
|
+
};
|
|
21
21
|
},
|
|
22
|
-
})
|
|
22
|
+
}),
|
|
23
23
|
)
|
|
24
24
|
.client((): RouterClient<typeof router> => {
|
|
25
25
|
const link = new RPCLink({
|
|
26
26
|
url: `${window.location.origin}/api/rpc`,
|
|
27
|
-
})
|
|
27
|
+
});
|
|
28
28
|
|
|
29
|
-
return createORPCClient(link)
|
|
30
|
-
})
|
|
29
|
+
return createORPCClient(link);
|
|
30
|
+
});
|
|
31
31
|
|
|
32
|
-
export const orpc = getORPCClient()
|
|
32
|
+
export const orpc = getORPCClient();
|