create-better-t-stack 3.1.5 → 3.1.7

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { createBtsCli } from "./src-DfqHfdEO.js";
2
+ import { createBtsCli } from "./src-DeOVz-ZI.js";
3
3
 
4
4
  //#region src/cli.ts
5
5
  createBtsCli().run();
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import { builder, createBtsCli, docs, init, router, sponsors } from "./src-DfqHfdEO.js";
2
+ import { builder, createBtsCli, docs, init, router, sponsors } from "./src-DeOVz-ZI.js";
3
3
 
4
4
  export { builder, createBtsCli, docs, init, router, sponsors };
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-better-t-stack",
3
- "version": "3.1.5",
3
+ "version": "3.1.7",
4
4
  "description": "A modern CLI tool for scaffolding end-to-end type-safe TypeScript projects with best practices and customizable configurations",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -0,0 +1,6 @@
1
+ import { authMiddleware } from "@/middleware/auth";
2
+ import { createServerFn } from "@tanstack/react-start";
3
+
4
+ export const getUser = createServerFn({ method: "GET" }).middleware([authMiddleware]).handler(async ({ context }) => {
5
+ return context.session
6
+ })
@@ -0,0 +1,31 @@
1
+ {{#if (eq backend "self")}}
2
+ import { auth } from "@{{projectName}}/auth";
3
+ import { createMiddleware } from "@tanstack/react-start";
4
+
5
+
6
+ export const authMiddleware = createMiddleware().server(async ({ next, request }) => {
7
+ const session = await auth.api.getSession({
8
+ headers: request.headers,
9
+ })
10
+ return next({
11
+ context: { session }
12
+ })
13
+ })
14
+ {{else}}
15
+ import { authClient } from "@/lib/auth-client";
16
+ import { createMiddleware } from "@tanstack/react-start";
17
+
18
+ export const authMiddleware = createMiddleware().server(
19
+ async ({ next, request }) => {
20
+ const session = await authClient.getSession({
21
+ fetchOptions: {
22
+ headers: request.headers,
23
+ throw: true
24
+ }
25
+ })
26
+ return next({
27
+ context: { session },
28
+ });
29
+ },
30
+ );
31
+ {{/if}}
@@ -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
- {{#if (eq api "trpc")}}
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
- component: RouteComponent,
15
- beforeLoad: async () => {
16
- const session = await authClient.getSession();
17
- if (!session.data) {
18
- redirect({
19
- to: "/login",
20
- throw: true
21
- });
22
- }
23
- {{#if (eq payments "polar")}}
24
- const {data: customerState} = await authClient.customer.state()
25
- return { session, customerState };
26
- {{else}}
27
- return { session };
28
- {{/if}}
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
- const { session{{#if (eq payments "polar")}}, customerState{{/if}} } = Route.useRouteContext();
38
+ const { session{{#if (eq payments "polar") }}, customerState{{/if}} } = Route.useRouteContext();
34
39
 
35
- {{#if (eq api "trpc")}}
36
- const trpc = useTRPC();
37
- const privateData = useQuery(trpc.privateData.queryOptions());
38
- {{/if}}
39
- {{#if (eq api "orpc")}}
40
- const privateData = useQuery(orpc.privateData.queryOptions());
41
- {{/if}}
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
- {{#if (eq payments "polar")}}
44
- const hasProSubscription = customerState?.activeSubscriptions?.length! > 0
45
- console.log("Active subscriptions:", customerState?.activeSubscriptions)
46
- {{/if}}
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
- return (
49
- <div>
50
- <h1>Dashboard</h1>
51
- <p>Welcome {session.data?.user.name}</p>
52
- {{#if ( or (eq api "orpc") (eq api "trpc"))}}
53
- <p>API: {privateData.data?.message}</p>
54
- {{/if}}
55
- {{#if (eq payments "polar")}}
56
- <p>Plan: {hasProSubscription ? "Pro" : "Free"}</p>
57
- {hasProSubscription ? (
58
- <Button onClick={async () => await authClient.customer.portal()}>
59
- Manage Subscription
60
- </Button>
61
- ) : (
62
- <Button onClick={async () => await authClient.checkout({ slug: "pro" })}>
63
- Upgrade to Pro
64
- </Button>
65
- )}
66
- {{/if}}
67
- </div>
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
+ });