create-better-t-stack 3.1.5 → 3.1.6
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/cli.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{src-DfqHfdEO.js → src-DeOVz-ZI.js} +11 -1
- package/package.json +1 -1
- package/templates/auth/better-auth/web/react/tanstack-start/src/functions/get-user.ts.hbs +6 -0
- package/templates/auth/better-auth/web/react/tanstack-start/src/middleware/auth.ts.hbs +12 -0
- package/templates/auth/better-auth/web/react/tanstack-start/src/routes/dashboard.tsx.hbs +67 -52
- package/templates/payments/polar/web/react/tanstack-start/src/functions/get-payment.ts.hbs +15 -0
package/dist/cli.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -2141,7 +2141,17 @@ async function setupRuler(config) {
|
|
|
2141
2141
|
opencode: { label: "OpenCode" },
|
|
2142
2142
|
crush: { label: "Crush" },
|
|
2143
2143
|
zed: { label: "Zed" },
|
|
2144
|
-
qwen: { label: "Qwen" }
|
|
2144
|
+
qwen: { label: "Qwen" },
|
|
2145
|
+
amazonqcli: { label: "Amazon Q CLI" },
|
|
2146
|
+
augmentcode: { label: "AugmentCode" },
|
|
2147
|
+
firebender: { label: "Firebender" },
|
|
2148
|
+
goose: { label: "Goose" },
|
|
2149
|
+
jules: { label: "Jules" },
|
|
2150
|
+
kiro: { label: "Kiro" },
|
|
2151
|
+
openhands: { label: "Open Hands" },
|
|
2152
|
+
roo: { label: "RooCode" },
|
|
2153
|
+
trae: { label: "Trae AI" },
|
|
2154
|
+
warp: { label: "Warp" }
|
|
2145
2155
|
}).map(([key, v]) => ({
|
|
2146
2156
|
value: key,
|
|
2147
2157
|
label: v.label
|
package/package.json
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { auth } from "@{{projectName}}/auth";
|
|
2
|
+
import { createMiddleware } from "@tanstack/react-start";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export const authMiddleware = createMiddleware().server(async ({ next, request }) => {
|
|
6
|
+
const session = await auth.api.getSession({
|
|
7
|
+
headers: request.headers,
|
|
8
|
+
})
|
|
9
|
+
return next({
|
|
10
|
+
context: { session }
|
|
11
|
+
})
|
|
12
|
+
})
|
|
@@ -1,69 +1,84 @@
|
|
|
1
|
+
import { getUser } from "@/functions/get-user";
|
|
2
|
+
{{#if (eq payments "polar") }}
|
|
1
3
|
import { Button } from "@/components/ui/button";
|
|
2
4
|
import { authClient } from "@/lib/auth-client";
|
|
3
|
-
{
|
|
5
|
+
import { getPayment } from "@/functions/get-payment";
|
|
6
|
+
{{/if}}
|
|
7
|
+
{{#if (eq api "trpc") }}
|
|
4
8
|
import { useTRPC } from "@/utils/trpc";
|
|
5
9
|
import { useQuery } from "@tanstack/react-query";
|
|
6
10
|
{{/if}}
|
|
7
|
-
{{#if (eq api "orpc")}}
|
|
11
|
+
{{#if (eq api "orpc") }}
|
|
8
12
|
import { orpc } from "@/utils/orpc";
|
|
9
13
|
import { useQuery } from "@tanstack/react-query";
|
|
10
14
|
{{/if}}
|
|
11
15
|
import { createFileRoute, redirect } from "@tanstack/react-router";
|
|
12
16
|
|
|
13
17
|
export const Route = createFileRoute("/dashboard")({
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
component: RouteComponent,
|
|
19
|
+
beforeLoad: async () => {
|
|
20
|
+
const session = await getUser();
|
|
21
|
+
{{#if (eq payments "polar") }}
|
|
22
|
+
const customerState = await getPayment();
|
|
23
|
+
return { session, customerState };
|
|
24
|
+
{{else}}
|
|
25
|
+
return { session };
|
|
26
|
+
{{/if}}
|
|
27
|
+
},
|
|
28
|
+
loader: async ({ context }) => {
|
|
29
|
+
if (!context.session) {
|
|
30
|
+
throw redirect({
|
|
31
|
+
to: "/login",
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
},
|
|
30
35
|
});
|
|
31
36
|
|
|
32
37
|
function RouteComponent() {
|
|
33
|
-
|
|
38
|
+
const { session{{#if (eq payments "polar") }}, customerState{{/if}} } = Route.useRouteContext();
|
|
34
39
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
{{#if (eq api "trpc") }}
|
|
41
|
+
const trpc = useTRPC();
|
|
42
|
+
const privateData = useQuery(trpc.privateData.queryOptions());
|
|
43
|
+
{{/if}}
|
|
44
|
+
{{#if (eq api "orpc") }}
|
|
45
|
+
const privateData = useQuery(orpc.privateData.queryOptions());
|
|
46
|
+
{{/if}}
|
|
42
47
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
{{#if (eq payments "polar") }}
|
|
49
|
+
const hasProSubscription = (customerState?.activeSubscriptions?.length ?? 0) > 0;
|
|
50
|
+
// For debugging: console.log("Active subscriptions:", customerState?.activeSubscriptions);
|
|
51
|
+
{{/if}}
|
|
47
52
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
53
|
+
return (
|
|
54
|
+
<div>
|
|
55
|
+
<h1>Dashboard</h1>
|
|
56
|
+
<p>Welcome {session?.user.name}</p>
|
|
57
|
+
{{#if (eq api "trpc") }}
|
|
58
|
+
<p>API: {privateData.data?.message}</p>
|
|
59
|
+
{{else if (eq api "orpc") }}
|
|
60
|
+
<p>API: {privateData.data?.message}</p>
|
|
61
|
+
{{/if}}
|
|
62
|
+
{{#if (eq payments "polar") }}
|
|
63
|
+
<p>Plan: {hasProSubscription ? "Pro" : "Free"}</p>
|
|
64
|
+
{hasProSubscription ? (
|
|
65
|
+
<Button
|
|
66
|
+
onClick={async function handlePortal() {
|
|
67
|
+
await authClient.customer.portal();
|
|
68
|
+
}}
|
|
69
|
+
>
|
|
70
|
+
Manage Subscription
|
|
71
|
+
</Button>
|
|
72
|
+
) : (
|
|
73
|
+
<Button
|
|
74
|
+
onClick={async function handleUpgrade() {
|
|
75
|
+
await authClient.checkout({ slug: "pro" });
|
|
76
|
+
}}
|
|
77
|
+
>
|
|
78
|
+
Upgrade to Pro
|
|
79
|
+
</Button>
|
|
80
|
+
)}
|
|
81
|
+
{{/if}}
|
|
82
|
+
</div>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { authClient } from "@/lib/auth-client";
|
|
2
|
+
import { authMiddleware } from "@/middleware/auth";
|
|
3
|
+
import { createServerFn } from "@tanstack/react-start";
|
|
4
|
+
import { getRequestHeaders } from "@tanstack/react-start/server";
|
|
5
|
+
|
|
6
|
+
export const getPayment = createServerFn({ method: "GET" })
|
|
7
|
+
.middleware([authMiddleware])
|
|
8
|
+
.handler(async () => {
|
|
9
|
+
const { data: customerState } = await authClient.customer.state({
|
|
10
|
+
fetchOptions: {
|
|
11
|
+
headers: getRequestHeaders()
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
return customerState;
|
|
15
|
+
});
|