@better-t-stack/template-generator 3.30.3 → 3.31.1

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.mjs CHANGED
@@ -393,7 +393,7 @@ function getDbScriptSupport(config) {
393
393
  };
394
394
  return {
395
395
  hasDbScripts: true,
396
- hasDbPush: true,
396
+ hasDbPush: !isD1Alchemy,
397
397
  hasDbGenerate: true,
398
398
  hasDbMigrate: config.orm === "prisma" || config.orm === "drizzle" && !isD1Alchemy,
399
399
  hasDbStudio: !isD1Alchemy,
@@ -466,7 +466,7 @@ function updateRootPackageJson(vfs, config) {
466
466
  if (backend !== "self" && backend !== "none") scripts["dev:server"] = pmConfig.filter(backendPackageName, "dev");
467
467
  if (backend === "convex") scripts["dev:setup"] = pmConfig.filter(backendPackageName, "dev:setup");
468
468
  if (needsDbScripts) {
469
- scripts["db:push"] = pmConfig.filter(dbPackageName, "db:push");
469
+ if (dbSupport.hasDbPush) scripts["db:push"] = pmConfig.filter(dbPackageName, "db:push");
470
470
  if (!isD1Alchemy) scripts["db:studio"] = pmConfig.filter(dbPackageName, "db:studio");
471
471
  if (orm === "prisma") {
472
472
  scripts["db:generate"] = pmConfig.filter(dbPackageName, "db:generate");
@@ -588,17 +588,18 @@ function updateDbPackageJson(vfs, config) {
588
588
  pkgJson.scripts = pkgJson.scripts || {};
589
589
  const scripts = pkgJson.scripts;
590
590
  const { database, orm, dbSetup } = config;
591
- const { isD1Alchemy } = getDbScriptSupport(config);
591
+ const dbSupport = getDbScriptSupport(config);
592
+ const { isD1Alchemy } = dbSupport;
592
593
  if (database !== "none") {
593
594
  if (database === "sqlite" && dbSetup !== "d1") scripts["db:local"] = "turso dev --db-file local.db";
594
595
  if (orm === "prisma") {
595
- scripts["db:push"] = "prisma db push";
596
+ if (dbSupport.hasDbPush) scripts["db:push"] = "prisma db push";
596
597
  scripts["db:generate"] = "prisma generate";
597
598
  scripts["db:migrate"] = "prisma migrate dev";
598
599
  scripts.postinstall ??= "prisma generate";
599
600
  if (!isD1Alchemy) scripts["db:studio"] = "prisma studio";
600
601
  } else if (orm === "drizzle") {
601
- scripts["db:push"] = "drizzle-kit push";
602
+ if (dbSupport.hasDbPush) scripts["db:push"] = "drizzle-kit push";
602
603
  scripts["db:generate"] = "drizzle-kit generate";
603
604
  if (!isD1Alchemy) {
604
605
  scripts["db:studio"] = "drizzle-kit studio";
@@ -2835,7 +2836,7 @@ function processReadme(vfs, config) {
2835
2836
  vfs.writeFile("README.md", content);
2836
2837
  }
2837
2838
  function generateReadmeContent(options) {
2838
- const { projectName, packageManager, database, auth, addons = [], orm = "drizzle", runtime = "bun", frontend = ["tanstack-router"], backend = "hono", api = "trpc", webDeploy, serverDeploy } = options;
2839
+ const { projectName, packageManager, database, auth, addons = [], orm = "drizzle", runtime = "bun", frontend = ["tanstack-router"], backend = "hono", api = "trpc", dbSetup, webDeploy, serverDeploy } = options;
2839
2840
  const isConvex = backend === "convex";
2840
2841
  const hasReactRouter = frontend.includes("react-router");
2841
2842
  const hasTanStackRouter = frontend.includes("tanstack-router");
@@ -2857,7 +2858,7 @@ This project was created with [Better-T-Stack](https://github.com/AmanVarshney01
2857
2858
 
2858
2859
  ## Features
2859
2860
 
2860
- ${generateFeaturesList(database, auth, addons, orm, runtime, frontend, backend, api)}
2861
+ ${generateFeaturesList(database, auth, addons, orm, runtime, frontend, backend, api, dbSetup)}
2861
2862
 
2862
2863
  ## Getting Started
2863
2864
 
@@ -3031,7 +3032,7 @@ function generateProjectStructure(config) {
3031
3032
  }
3032
3033
  return structure.join("\n");
3033
3034
  }
3034
- function generateFeaturesList(database, auth, addons, orm, runtime, frontend, backend, api) {
3035
+ function generateFeaturesList(database, auth, addons, orm, runtime, frontend, backend, api, dbSetup) {
3035
3036
  const isConvex = backend === "convex";
3036
3037
  const hasNative = hasNativeFrontend(frontend);
3037
3038
  const hasAppWebFrontend = hasWebFrontend(frontend);
@@ -3074,16 +3075,20 @@ function generateFeaturesList(database, auth, addons, orm, runtime, frontend, ba
3074
3075
  const runtimeName = runtime === "bun" ? "Bun" : runtime === "node" ? "Node.js" : runtime;
3075
3076
  features.push(`- **${runtimeName}** - Runtime environment`);
3076
3077
  }
3077
- if (database !== "none" && !isConvex) features.push(`- **${{
3078
- drizzle: "Drizzle",
3079
- prisma: "Prisma",
3080
- mongoose: "Mongoose"
3081
- }[orm] || "ORM"}** - TypeScript-first ORM`, `- **${{
3082
- sqlite: "SQLite/Turso",
3083
- postgres: "PostgreSQL",
3084
- mysql: "MySQL",
3085
- mongodb: "MongoDB"
3086
- }[database] || "Database"}** - Database engine`);
3078
+ if (database !== "none" && !isConvex) {
3079
+ const ormNames = {
3080
+ drizzle: "Drizzle",
3081
+ prisma: "Prisma",
3082
+ mongoose: "Mongoose"
3083
+ };
3084
+ const dbNames = {
3085
+ sqlite: dbSetup === "d1" ? "Cloudflare D1" : "SQLite/Turso",
3086
+ postgres: "PostgreSQL",
3087
+ mysql: "MySQL",
3088
+ mongodb: "MongoDB"
3089
+ };
3090
+ features.push(`- **${ormNames[orm] || "ORM"}** - TypeScript-first ORM`, `- **${dbNames[database] || "Database"}** - Database engine`);
3091
+ }
3087
3092
  if (auth !== "none") {
3088
3093
  const authLabel = auth === "clerk" ? "Clerk" : "Better-Auth";
3089
3094
  features.push(`- **Authentication** - ${authLabel}`);
@@ -3114,7 +3119,27 @@ function generateDatabaseSetup(config, packageManagerRunCmd) {
3114
3119
  none: "ORM"
3115
3120
  }[orm] || orm}`;
3116
3121
  const dbSupport = getDbScriptSupport(config);
3122
+ const isD1Alchemy = dbSupport.isD1Alchemy;
3117
3123
  let setup = "## Database Setup\n\n";
3124
+ if (isD1Alchemy) {
3125
+ const steps = [];
3126
+ if (dbSupport.hasDbGenerate) steps.push(`${steps.length + 1}. ${orm === "prisma" ? "Generate the Prisma client" : "Generate migration files"}:
3127
+ \`\`\`bash
3128
+ ${packageManagerRunCmd} db:generate
3129
+ \`\`\``);
3130
+ if (dbSupport.hasDbMigrate) steps.push(`${steps.length + 1}. Create and apply Prisma migrations locally:
3131
+ \`\`\`bash
3132
+ ${packageManagerRunCmd} db:migrate
3133
+ \`\`\``);
3134
+ return `${setup}This project uses Cloudflare D1 (SQLite)${ormDesc}.
3135
+
3136
+ Runtime database access uses the Cloudflare \`DB\` binding from \`packages/infra/alchemy.run.ts\`. If a local \`DATABASE_URL\` is present, it is only for database tooling.
3137
+
3138
+ Alchemy provisions the D1 database and applies migrations during \`dev\` and \`deploy\`.
3139
+
3140
+ ${steps.join("\n\n")}
3141
+ `;
3142
+ }
3118
3143
  const dbDescriptions = {
3119
3144
  sqlite: `This project uses SQLite${ormDesc}.
3120
3145
 
@@ -3170,7 +3195,7 @@ function generateScriptsList(packageManagerRunCmd, config, hasNative) {
3170
3195
  scripts += `\n- \`${packageManagerRunCmd} check-types\`: Check TypeScript types across all apps`;
3171
3196
  if (hasNative) scripts += `\n- \`${packageManagerRunCmd} dev:native\`: Start the React Native/Expo development server`;
3172
3197
  if (dbSupport.hasDbScripts) {
3173
- scripts += `\n- \`${packageManagerRunCmd} db:push\`: Push schema changes to database`;
3198
+ if (dbSupport.hasDbPush) scripts += `\n- \`${packageManagerRunCmd} db:push\`: Push schema changes to database`;
3174
3199
  if (dbSupport.hasDbGenerate) scripts += `\n- \`${packageManagerRunCmd} db:generate\`: Generate database client/types`;
3175
3200
  if (dbSupport.hasDbMigrate) scripts += `\n- \`${packageManagerRunCmd} db:migrate\`: Run database migrations`;
3176
3201
  if (dbSupport.hasDbStudio) scripts += `\n- \`${packageManagerRunCmd} db:studio\`: Open database studio UI`;
@@ -3282,7 +3307,7 @@ function generateTurboConfig(config) {
3282
3307
  }
3283
3308
  function getBaseTasks(frontend) {
3284
3309
  const buildOutputs = ["dist/**"];
3285
- if (frontend.includes("next")) buildOutputs.push(".next/**");
3310
+ if (frontend.includes("next")) buildOutputs.push(".next/**", "!.next/cache/**");
3286
3311
  if (frontend.includes("nuxt")) buildOutputs.push(".nuxt/**", ".output/**");
3287
3312
  if (frontend.includes("svelte")) buildOutputs.push(".svelte-kit/**", "build/**");
3288
3313
  if (frontend.includes("astro")) buildOutputs.push(".astro/**");
@@ -5398,18 +5423,29 @@ import { getClerkAuthToken } from "@/utils/clerk-auth";
5398
5423
  {{/if}}
5399
5424
  {{/if}}
5400
5425
 
5401
- export const queryClient = new QueryClient({
5402
- queryCache: new QueryCache({
5403
- onError: (error, query) => {
5404
- toast.error(\`Error: \${error.message}\`, {
5405
- action: {
5406
- label: "retry",
5407
- onClick: query.invalidate,
5408
- },
5409
- });
5410
- },
5411
- }),
5412
- });
5426
+ export function createQueryClient() {
5427
+ return new QueryClient({
5428
+ queryCache: new QueryCache({
5429
+ onError: (error, query) => {
5430
+ toast.error(\`Error: \${error.message}\`, {
5431
+ action: {
5432
+ label: "retry",
5433
+ onClick: () => {
5434
+ query.invalidate();
5435
+ },
5436
+ },
5437
+ });
5438
+ },
5439
+ }),
5440
+ {{#if (includes frontend "tanstack-start")}}
5441
+ defaultOptions: { queries: { staleTime: 60 * 1000 } },
5442
+ {{/if}}
5443
+ });
5444
+ }
5445
+
5446
+ {{#unless (includes frontend "tanstack-start")}}
5447
+ export const queryClient = createQueryClient();
5448
+ {{/unless}}
5413
5449
 
5414
5450
  {{#if (and (includes frontend "tanstack-start") (eq backend "self"))}}
5415
5451
  const getORPCClient = createIsomorphicFn()
@@ -6109,7 +6145,9 @@ export const queryClient = new QueryClient({
6109
6145
  toast.error(error.message, {
6110
6146
  action: {
6111
6147
  label: "retry",
6112
- onClick: query.invalidate,
6148
+ onClick: () => {
6149
+ query.invalidate();
6150
+ },
6113
6151
  },
6114
6152
  });
6115
6153
  },
@@ -6179,7 +6217,9 @@ export const queryClient = new QueryClient({
6179
6217
  toast.error(error.message, {
6180
6218
  action: {
6181
6219
  label: "retry",
6182
- onClick: query.invalidate,
6220
+ onClick: () => {
6221
+ query.invalidate();
6222
+ },
6183
6223
  },
6184
6224
  });
6185
6225
  },
@@ -8889,28 +8929,20 @@ export const authClient = createAuthClient({
8889
8929
  plugins: [convexClient(), crossDomainClient()],
8890
8930
  });
8891
8931
  `],
8892
- ["auth/better-auth/convex/web/react/tanstack-router/src/routes/dashboard.tsx.hbs", `import SignInForm from "@/components/sign-in-form";
8893
- import SignUpForm from "@/components/sign-up-form";
8894
- import UserMenu from "@/components/user-menu";
8932
+ ["auth/better-auth/convex/web/react/tanstack-router/src/routes/_auth/dashboard.tsx.hbs", `import UserMenu from "@/components/user-menu";
8895
8933
  {{#if (eq payments "polar")}}
8896
8934
  import { CheckoutLink, CustomerPortalLink } from "@convex-dev/polar/react";
8897
8935
  import { buttonVariants } from "@{{projectName}}/ui/components/button";
8898
8936
  {{/if}}
8899
8937
  import { api } from "@{{projectName}}/backend/convex/_generated/api";
8900
8938
  import { createFileRoute } from "@tanstack/react-router";
8901
- import {
8902
- Authenticated,
8903
- AuthLoading,
8904
- Unauthenticated,
8905
- useQuery,
8906
- } from "convex/react";
8907
- import { useState } from "react";
8939
+ import { useQuery } from "convex/react";
8908
8940
 
8909
- export const Route = createFileRoute("/dashboard")({
8910
- component: RouteComponent,
8941
+ export const Route = createFileRoute("/_auth/dashboard")({
8942
+ component: DashboardContent,
8911
8943
  });
8912
8944
 
8913
- function PrivateDashboardContent() {
8945
+ function DashboardContent() {
8914
8946
  const privateData = useQuery(api.privateData.get);
8915
8947
  {{#if (eq payments "polar")}}
8916
8948
  const products = useQuery(api.polar.listAllProducts);
@@ -8954,14 +8986,24 @@ function PrivateDashboardContent() {
8954
8986
  </div>
8955
8987
  );
8956
8988
  }
8989
+ `],
8990
+ ["auth/better-auth/convex/web/react/tanstack-router/src/routes/_auth/route.tsx.hbs", `import SignInForm from "@/components/sign-in-form";
8991
+ import SignUpForm from "@/components/sign-up-form";
8992
+ import { Outlet, createFileRoute } from "@tanstack/react-router";
8993
+ import { Authenticated, AuthLoading, Unauthenticated } from "convex/react";
8994
+ import { useState } from "react";
8957
8995
 
8958
- function RouteComponent() {
8996
+ export const Route = createFileRoute("/_auth")({
8997
+ component: AuthLayout,
8998
+ });
8999
+
9000
+ function AuthLayout() {
8959
9001
  const [showSignIn, setShowSignIn] = useState(false);
8960
9002
 
8961
9003
  return (
8962
9004
  <>
8963
9005
  <Authenticated>
8964
- <PrivateDashboardContent />
9006
+ <Outlet />
8965
9007
  </Authenticated>
8966
9008
  <Unauthenticated>
8967
9009
  {showSignIn ? (
@@ -9338,40 +9380,20 @@ export const {
9338
9380
  convexSiteUrl: env.VITE_CONVEX_SITE_URL,
9339
9381
  });
9340
9382
  `],
9341
- ["auth/better-auth/convex/web/react/tanstack-start/src/routes/api/auth/$.ts.hbs", `import { createFileRoute } from "@tanstack/react-router";
9342
- import { handler } from "@/lib/auth-server";
9343
-
9344
- export const Route = createFileRoute("/api/auth/$")({
9345
- server: {
9346
- handlers: {
9347
- GET: ({ request }) => handler(request),
9348
- POST: ({ request }) => handler(request),
9349
- },
9350
- },
9351
- });
9352
- `],
9353
- ["auth/better-auth/convex/web/react/tanstack-start/src/routes/dashboard.tsx.hbs", `import SignInForm from "@/components/sign-in-form";
9354
- import SignUpForm from "@/components/sign-up-form";
9355
- import UserMenu from "@/components/user-menu";
9383
+ ["auth/better-auth/convex/web/react/tanstack-start/src/routes/_auth/dashboard.tsx.hbs", `import UserMenu from "@/components/user-menu";
9356
9384
  {{#if (eq payments "polar")}}
9357
9385
  import { CheckoutLink, CustomerPortalLink } from "@convex-dev/polar/react";
9358
9386
  import { buttonVariants } from "@{{projectName}}/ui/components/button";
9359
9387
  {{/if}}
9360
9388
  import { api } from "@{{projectName}}/backend/convex/_generated/api";
9361
9389
  import { createFileRoute } from "@tanstack/react-router";
9362
- import {
9363
- Authenticated,
9364
- AuthLoading,
9365
- Unauthenticated,
9366
- useQuery,
9367
- } from "convex/react";
9368
- import { useState } from "react";
9390
+ import { useQuery } from "convex/react";
9369
9391
 
9370
- export const Route = createFileRoute("/dashboard")({
9371
- component: RouteComponent,
9392
+ export const Route = createFileRoute("/_auth/dashboard")({
9393
+ component: DashboardContent,
9372
9394
  });
9373
9395
 
9374
- function PrivateDashboardContent() {
9396
+ function DashboardContent() {
9375
9397
  const privateData = useQuery(api.privateData.get);
9376
9398
  {{#if (eq payments "polar")}}
9377
9399
  const products = useQuery(api.polar.listAllProducts);
@@ -9415,14 +9437,24 @@ function PrivateDashboardContent() {
9415
9437
  </div>
9416
9438
  );
9417
9439
  }
9440
+ `],
9441
+ ["auth/better-auth/convex/web/react/tanstack-start/src/routes/_auth/route.tsx.hbs", `import SignInForm from "@/components/sign-in-form";
9442
+ import SignUpForm from "@/components/sign-up-form";
9443
+ import { Outlet, createFileRoute } from "@tanstack/react-router";
9444
+ import { Authenticated, AuthLoading, Unauthenticated } from "convex/react";
9445
+ import { useState } from "react";
9418
9446
 
9419
- function RouteComponent() {
9447
+ export const Route = createFileRoute("/_auth")({
9448
+ component: AuthLayout,
9449
+ });
9450
+
9451
+ function AuthLayout() {
9420
9452
  const [showSignIn, setShowSignIn] = useState(false);
9421
9453
 
9422
9454
  return (
9423
9455
  <>
9424
9456
  <Authenticated>
9425
- <PrivateDashboardContent />
9457
+ <Outlet />
9426
9458
  </Authenticated>
9427
9459
  <Unauthenticated>
9428
9460
  {showSignIn ? (
@@ -9437,6 +9469,18 @@ function RouteComponent() {
9437
9469
  </>
9438
9470
  );
9439
9471
  }
9472
+ `],
9473
+ ["auth/better-auth/convex/web/react/tanstack-start/src/routes/api/auth/$.ts.hbs", `import { createFileRoute } from "@tanstack/react-router";
9474
+ import { handler } from "@/lib/auth-server";
9475
+
9476
+ export const Route = createFileRoute("/api/auth/$")({
9477
+ server: {
9478
+ handlers: {
9479
+ GET: ({ request }) => handler(request),
9480
+ POST: ({ request }) => handler(request),
9481
+ },
9482
+ },
9483
+ });
9440
9484
  `],
9441
9485
  ["auth/better-auth/fullstack/astro/src/env.d.ts.hbs", `/// <reference path="../.astro/types.d.ts" />
9442
9486
 
@@ -13414,7 +13458,7 @@ onMounted(async () => {
13414
13458
  })
13415
13459
 
13416
13460
  const hasProSubscription = computed(() =>
13417
- customerState.value?.activeSubscriptions?.length! > 0
13461
+ (customerState.value?.activeSubscriptions?.length ?? 0) > 0
13418
13462
  )
13419
13463
  {{/if}}
13420
13464
  <\/script>
@@ -13585,8 +13629,7 @@ export default function Dashboard({
13585
13629
  {{/if}}
13586
13630
 
13587
13631
  {{#if (eq payments "polar")}}
13588
- const hasProSubscription = customerState?.activeSubscriptions?.length! > 0;
13589
- console.log("Active subscriptions:", customerState?.activeSubscriptions);
13632
+ const hasProSubscription = (customerState?.activeSubscriptions?.length ?? 0) > 0;
13590
13633
  {{/if}}
13591
13634
 
13592
13635
  return (
@@ -14408,7 +14451,7 @@ import { orpc } from "@/utils/orpc";
14408
14451
  {{#if (eq api "trpc")}}
14409
14452
  import { trpc } from "@/utils/trpc";
14410
14453
  {{/if}}
14411
- {{#if ( or (eq api "orpc") (eq api "trpc"))}}
14454
+ {{#if (or (eq api "orpc") (eq api "trpc"))}}
14412
14455
  import { useQuery } from "@tanstack/react-query";
14413
14456
  {{/if}}
14414
14457
  import { useEffect, useState } from "react";
@@ -14452,15 +14495,14 @@ export default function Dashboard() {
14452
14495
  }
14453
14496
 
14454
14497
  {{#if (eq payments "polar")}}
14455
- const hasProSubscription = customerState?.activeSubscriptions?.length! > 0;
14456
- console.log("Active subscriptions:", customerState?.activeSubscriptions);
14498
+ const hasProSubscription = (customerState?.activeSubscriptions?.length ?? 0) > 0;
14457
14499
  {{/if}}
14458
14500
 
14459
14501
  return (
14460
14502
  <div>
14461
14503
  <h1>Dashboard</h1>
14462
14504
  <p>Welcome {session?.user.name}</p>
14463
- {{#if ( or (eq api "orpc") (eq api "trpc"))}}
14505
+ {{#if (or (eq api "orpc") (eq api "trpc"))}}
14464
14506
  <p>API: {privateData.data?.message}</p>
14465
14507
  {{/if}}
14466
14508
  {{#if (eq payments "polar")}}
@@ -14854,38 +14896,23 @@ export default function UserMenu() {
14854
14896
  );
14855
14897
  }
14856
14898
  `],
14857
- ["auth/better-auth/web/react/tanstack-router/src/routes/dashboard.tsx.hbs", `{{#if (eq payments "polar")}}
14899
+ ["auth/better-auth/web/react/tanstack-router/src/routes/_auth/dashboard.tsx.hbs", `{{#if (eq payments "polar")}}
14858
14900
  import { Button } from "@{{projectName}}/ui/components/button";
14859
- {{/if}}
14860
14901
  import { authClient } from "@/lib/auth-client";
14902
+ {{/if}}
14861
14903
  {{#if (eq api "orpc")}}
14862
14904
  import { orpc } from "@/utils/orpc";
14863
14905
  {{/if}}
14864
14906
  {{#if (eq api "trpc")}}
14865
14907
  import { trpc } from "@/utils/trpc";
14866
14908
  {{/if}}
14867
- {{#if ( or (eq api "orpc") (eq api "trpc"))}}
14909
+ {{#if (or (eq api "orpc") (eq api "trpc"))}}
14868
14910
  import { useQuery } from "@tanstack/react-query";
14869
14911
  {{/if}}
14870
- import { createFileRoute, redirect } from "@tanstack/react-router";
14912
+ import { createFileRoute } from "@tanstack/react-router";
14871
14913
 
14872
- export const Route = createFileRoute("/dashboard")({
14914
+ export const Route = createFileRoute("/_auth/dashboard")({
14873
14915
  component: RouteComponent,
14874
- beforeLoad: async () => {
14875
- const session = await authClient.getSession();
14876
- if (!session.data) {
14877
- redirect({
14878
- to: "/login",
14879
- throw: true
14880
- });
14881
- }
14882
- {{#if (eq payments "polar")}}
14883
- const {data: customerState} = await authClient.customer.state()
14884
- return { session, customerState };
14885
- {{else}}
14886
- return { session };
14887
- {{/if}}
14888
- }
14889
14916
  });
14890
14917
 
14891
14918
  function RouteComponent() {
@@ -14899,15 +14926,14 @@ function RouteComponent() {
14899
14926
  {{/if}}
14900
14927
 
14901
14928
  {{#if (eq payments "polar")}}
14902
- const hasProSubscription = customerState?.activeSubscriptions?.length! > 0
14903
- console.log("Active subscriptions:", customerState?.activeSubscriptions)
14929
+ const hasProSubscription = (customerState?.activeSubscriptions?.length ?? 0) > 0;
14904
14930
  {{/if}}
14905
14931
 
14906
14932
  return (
14907
14933
  <div>
14908
14934
  <h1>Dashboard</h1>
14909
14935
  <p>Welcome {session.data?.user.name}</p>
14910
- {{#if ( or (eq api "orpc") (eq api "trpc"))}}
14936
+ {{#if (or (eq api "orpc") (eq api "trpc"))}}
14911
14937
  <p>API: {privateData.data?.message}</p>
14912
14938
  {{/if}}
14913
14939
  {{#if (eq payments "polar")}}
@@ -14925,6 +14951,31 @@ function RouteComponent() {
14925
14951
  </div>
14926
14952
  );
14927
14953
  }
14954
+ `],
14955
+ ["auth/better-auth/web/react/tanstack-router/src/routes/_auth/route.tsx.hbs", `import { authClient } from "@/lib/auth-client";
14956
+ import { Outlet, createFileRoute, redirect } from "@tanstack/react-router";
14957
+
14958
+ export const Route = createFileRoute("/_auth")({
14959
+ component: AuthLayout,
14960
+ beforeLoad: async () => {
14961
+ const session = await authClient.getSession();
14962
+ if (!session.data) {
14963
+ throw redirect({
14964
+ to: "/login",
14965
+ });
14966
+ }
14967
+ {{#if (eq payments "polar")}}
14968
+ const { data: customerState } = await authClient.customer.state();
14969
+ return { session, customerState };
14970
+ {{else}}
14971
+ return { session };
14972
+ {{/if}}
14973
+ },
14974
+ });
14975
+
14976
+ function AuthLayout() {
14977
+ return <Outlet />;
14978
+ }
14928
14979
  `],
14929
14980
  ["auth/better-auth/web/react/tanstack-router/src/routes/login.tsx.hbs", `import SignInForm from "@/components/sign-in-form";
14930
14981
  import SignUpForm from "@/components/sign-up-form";
@@ -15348,11 +15399,9 @@ export const authMiddleware = createMiddleware().server(
15348
15399
  );
15349
15400
  {{/if}}
15350
15401
  `],
15351
- ["auth/better-auth/web/react/tanstack-start/src/routes/dashboard.tsx.hbs", `import { getUser } from "@/functions/get-user";
15352
- {{#if (eq payments "polar") }}
15402
+ ["auth/better-auth/web/react/tanstack-start/src/routes/_auth/dashboard.tsx.hbs", `{{#if (eq payments "polar") }}
15353
15403
  import { Button } from "@{{projectName}}/ui/components/button";
15354
15404
  import { authClient } from "@/lib/auth-client";
15355
- import { getPayment } from "@/functions/get-payment";
15356
15405
  {{/if}}
15357
15406
  {{#if (eq api "trpc") }}
15358
15407
  import { useTRPC } from "@/utils/trpc";
@@ -15362,26 +15411,10 @@ import { useQuery } from "@tanstack/react-query";
15362
15411
  import { orpc } from "@/utils/orpc";
15363
15412
  import { useQuery } from "@tanstack/react-query";
15364
15413
  {{/if}}
15365
- import { createFileRoute, redirect } from "@tanstack/react-router";
15414
+ import { createFileRoute } from "@tanstack/react-router";
15366
15415
 
15367
- export const Route = createFileRoute("/dashboard")({
15416
+ export const Route = createFileRoute("/_auth/dashboard")({
15368
15417
  component: RouteComponent,
15369
- beforeLoad: async () => {
15370
- const session = await getUser();
15371
- {{#if (eq payments "polar") }}
15372
- const customerState = await getPayment();
15373
- return { session, customerState };
15374
- {{else}}
15375
- return { session };
15376
- {{/if}}
15377
- },
15378
- loader: async ({ context }) => {
15379
- if (!context.session) {
15380
- throw redirect({
15381
- to: "/login",
15382
- });
15383
- }
15384
- },
15385
15418
  });
15386
15419
 
15387
15420
  function RouteComponent() {
@@ -15397,13 +15430,16 @@ function RouteComponent() {
15397
15430
 
15398
15431
  {{#if (eq payments "polar") }}
15399
15432
  const hasProSubscription = (customerState?.activeSubscriptions?.length ?? 0) > 0;
15400
- // For debugging: console.log("Active subscriptions:", customerState?.activeSubscriptions);
15401
15433
  {{/if}}
15402
15434
 
15403
15435
  return (
15404
15436
  <div>
15405
15437
  <h1>Dashboard</h1>
15438
+ {{#if (eq backend "self")}}
15406
15439
  <p>Welcome {session?.user.name}</p>
15440
+ {{else}}
15441
+ <p>Welcome {session.data?.user.name}</p>
15442
+ {{/if}}
15407
15443
  {{#if (eq api "trpc") }}
15408
15444
  <p>API: {privateData.data?.message}</p>
15409
15445
  {{else if (eq api "orpc") }}
@@ -15431,7 +15467,67 @@ function RouteComponent() {
15431
15467
  {{/if}}
15432
15468
  </div>
15433
15469
  );
15434
- }`],
15470
+ }
15471
+ `],
15472
+ ["auth/better-auth/web/react/tanstack-start/src/routes/_auth/route.tsx.hbs", `{{#if (eq backend "self")}}
15473
+ import { getUser } from "@/functions/get-user";
15474
+ {{else}}
15475
+ import { authClient } from "@/lib/auth-client";
15476
+ {{/if}}
15477
+ {{#if (and (eq backend "self") (eq payments "polar"))}}
15478
+ import { getPayment } from "@/functions/get-payment";
15479
+ {{/if}}
15480
+ import { Outlet, createFileRoute, redirect } from "@tanstack/react-router";
15481
+
15482
+ export const Route = createFileRoute("/_auth")({
15483
+ {{#unless (eq backend "self")}}
15484
+ ssr: false,
15485
+ {{/unless}}
15486
+ component: AuthLayout,
15487
+ beforeLoad: async () => {
15488
+ {{#if (eq backend "self")}}
15489
+ const session = await getUser();
15490
+ if (!session) {
15491
+ throw redirect({
15492
+ to: "/login",
15493
+ });
15494
+ }
15495
+ {{#if (eq payments "polar") }}
15496
+ const customerState = await getPayment();
15497
+ return { session, customerState };
15498
+ {{else}}
15499
+ return { session };
15500
+ {{/if}}
15501
+ {{else}}
15502
+ const session = await authClient.getSession();
15503
+ if (!session.data) {
15504
+ throw redirect({
15505
+ to: "/login",
15506
+ });
15507
+ }
15508
+ {{#if (eq payments "polar") }}
15509
+ const { data: customerState } = await authClient.customer.state();
15510
+ return { session, customerState };
15511
+ {{else}}
15512
+ return { session };
15513
+ {{/if}}
15514
+ {{/if}}
15515
+ },
15516
+ {{#if (eq backend "self")}}
15517
+ loader: async ({ context }) => {
15518
+ if (!context.session) {
15519
+ throw redirect({
15520
+ to: "/login",
15521
+ });
15522
+ }
15523
+ },
15524
+ {{/if}}
15525
+ });
15526
+
15527
+ function AuthLayout() {
15528
+ return <Outlet />;
15529
+ }
15530
+ `],
15435
15531
  ["auth/better-auth/web/react/tanstack-start/src/routes/login.tsx.hbs", `import SignInForm from "@/components/sign-in-form";
15436
15532
  import SignUpForm from "@/components/sign-up-form";
15437
15533
  import { createFileRoute } from "@tanstack/react-router";
@@ -15834,7 +15930,7 @@ function RouteComponent() {
15834
15930
 
15835
15931
  {{#if (eq payments "polar")}}
15836
15932
  const hasProSubscription = () =>
15837
- customerState?.activeSubscriptions?.length! > 0;
15933
+ (customerState?.activeSubscriptions?.length ?? 0) > 0;
15838
15934
  {{/if}}
15839
15935
 
15840
15936
  return (
@@ -16905,33 +17001,42 @@ export default function Dashboard() {
16905
17001
  );
16906
17002
  }
16907
17003
  `],
16908
- ["auth/clerk/convex/web/react/tanstack-router/src/routes/dashboard.tsx.hbs", `import { SignInButton, UserButton, useUser } from "@clerk/react";
17004
+ ["auth/clerk/convex/web/react/tanstack-router/src/routes/_auth/dashboard.tsx.hbs", `import { UserButton, useUser } from "@clerk/react";
16909
17005
  import { api } from "@{{projectName}}/backend/convex/_generated/api";
16910
17006
  import { createFileRoute } from "@tanstack/react-router";
16911
- import {
16912
- Authenticated,
16913
- AuthLoading,
16914
- Unauthenticated,
16915
- useQuery,
16916
- } from "convex/react";
17007
+ import { useQuery } from "convex/react";
16917
17008
 
16918
- export const Route = createFileRoute("/dashboard")({
17009
+ export const Route = createFileRoute("/_auth/dashboard")({
16919
17010
  component: RouteComponent,
16920
17011
  });
16921
17012
 
16922
17013
  function RouteComponent() {
16923
17014
  const privateData = useQuery(api.privateData.get);
16924
- const user = useUser()
17015
+ const user = useUser();
16925
17016
 
17017
+ return (
17018
+ <div>
17019
+ <h1>Dashboard</h1>
17020
+ <p>Welcome {user.user?.fullName}</p>
17021
+ <p>privateData: {privateData?.message}</p>
17022
+ <UserButton />
17023
+ </div>
17024
+ );
17025
+ }
17026
+ `],
17027
+ ["auth/clerk/convex/web/react/tanstack-router/src/routes/_auth/route.tsx.hbs", `import { SignInButton } from "@clerk/react";
17028
+ import { Outlet, createFileRoute } from "@tanstack/react-router";
17029
+ import { Authenticated, AuthLoading, Unauthenticated } from "convex/react";
17030
+
17031
+ export const Route = createFileRoute("/_auth")({
17032
+ component: AuthLayout,
17033
+ });
17034
+
17035
+ function AuthLayout() {
16926
17036
  return (
16927
17037
  <>
16928
17038
  <Authenticated>
16929
- <div>
16930
- <h1>Dashboard</h1>
16931
- <p>Welcome {user.user?.fullName}</p>
16932
- <p>privateData: {privateData?.message}</p>
16933
- <UserButton />
16934
- </div>
17039
+ <Outlet />
16935
17040
  </Authenticated>
16936
17041
  <Unauthenticated>
16937
17042
  <SignInButton />
@@ -16943,17 +17048,12 @@ function RouteComponent() {
16943
17048
  );
16944
17049
  }
16945
17050
  `],
16946
- ["auth/clerk/convex/web/react/tanstack-start/src/routes/dashboard.tsx.hbs", `import { SignInButton, UserButton, useUser } from "@clerk/tanstack-react-start";
17051
+ ["auth/clerk/convex/web/react/tanstack-start/src/routes/_auth/dashboard.tsx.hbs", `import { UserButton, useUser } from "@clerk/tanstack-react-start";
16947
17052
  import { api } from "@{{projectName}}/backend/convex/_generated/api";
16948
17053
  import { createFileRoute } from "@tanstack/react-router";
16949
- import {
16950
- Authenticated,
16951
- AuthLoading,
16952
- Unauthenticated,
16953
- useQuery,
16954
- } from "convex/react";
17054
+ import { useQuery } from "convex/react";
16955
17055
 
16956
- export const Route = createFileRoute("/dashboard")({
17056
+ export const Route = createFileRoute("/_auth/dashboard")({
16957
17057
  component: RouteComponent,
16958
17058
  });
16959
17059
 
@@ -16961,15 +17061,29 @@ function RouteComponent() {
16961
17061
  const privateData = useQuery(api.privateData.get);
16962
17062
  const user = useUser();
16963
17063
 
17064
+ return (
17065
+ <div>
17066
+ <h1>Dashboard</h1>
17067
+ <p>Welcome {user.user?.fullName}</p>
17068
+ <p>privateData: {privateData?.message}</p>
17069
+ <UserButton />
17070
+ </div>
17071
+ );
17072
+ }
17073
+ `],
17074
+ ["auth/clerk/convex/web/react/tanstack-start/src/routes/_auth/route.tsx.hbs", `import { SignInButton } from "@clerk/tanstack-react-start";
17075
+ import { Outlet, createFileRoute } from "@tanstack/react-router";
17076
+ import { Authenticated, AuthLoading, Unauthenticated } from "convex/react";
17077
+
17078
+ export const Route = createFileRoute("/_auth")({
17079
+ component: AuthLayout,
17080
+ });
17081
+
17082
+ function AuthLayout() {
16964
17083
  return (
16965
17084
  <>
16966
17085
  <Authenticated>
16967
- <div>
16968
- <h1>Dashboard</h1>
16969
- <p>Welcome {user.user?.fullName}</p>
16970
- <p>privateData: {privateData?.message}</p>
16971
- <UserButton />
16972
- </div>
17086
+ <Outlet />
16973
17087
  </Authenticated>
16974
17088
  <Unauthenticated>
16975
17089
  <SignInButton />
@@ -17651,7 +17765,7 @@ export default function Dashboard() {
17651
17765
  );
17652
17766
  }
17653
17767
  `],
17654
- ["auth/clerk/web/react/tanstack-router/src/routes/dashboard.tsx.hbs", `{{#if (eq api "orpc")}}
17768
+ ["auth/clerk/web/react/tanstack-router/src/routes/_auth/dashboard.tsx.hbs", `{{#if (eq api "orpc")}}
17655
17769
  import { useQuery } from "@tanstack/react-query";
17656
17770
  import { orpc } from "@/utils/orpc";
17657
17771
  {{/if}}
@@ -17659,10 +17773,10 @@ import { orpc } from "@/utils/orpc";
17659
17773
  import { useQuery } from "@tanstack/react-query";
17660
17774
  import { trpc } from "@/utils/trpc";
17661
17775
  {{/if}}
17662
- import { SignInButton, UserButton, useUser } from "@clerk/react";
17776
+ import { UserButton, useUser } from "@clerk/react";
17663
17777
  import { createFileRoute } from "@tanstack/react-router";
17664
17778
 
17665
- export const Route = createFileRoute("/dashboard")({
17779
+ export const Route = createFileRoute("/_auth/dashboard")({
17666
17780
  component: RouteComponent,
17667
17781
  });
17668
17782
 
@@ -17689,6 +17803,28 @@ function RouteComponent() {
17689
17803
  });
17690
17804
  {{/if}}
17691
17805
 
17806
+ return (
17807
+ <div className="space-y-4 p-6">
17808
+ <h1 className="text-2xl font-semibold">Dashboard</h1>
17809
+ <p>Welcome {displayName}</p>
17810
+ {{#if (or (eq api "orpc") (eq api "trpc"))}}
17811
+ <p>API: {privateData.data?.message}</p>
17812
+ {{/if}}
17813
+ <UserButton />
17814
+ </div>
17815
+ );
17816
+ }
17817
+ `],
17818
+ ["auth/clerk/web/react/tanstack-router/src/routes/_auth/route.tsx.hbs", `import { SignInButton, useUser } from "@clerk/react";
17819
+ import { Outlet, createFileRoute } from "@tanstack/react-router";
17820
+
17821
+ export const Route = createFileRoute("/_auth")({
17822
+ component: AuthLayout,
17823
+ });
17824
+
17825
+ function AuthLayout() {
17826
+ const user = useUser();
17827
+
17692
17828
  if (!user.isLoaded) {
17693
17829
  return <div className="p-6">Loading...</div>;
17694
17830
  }
@@ -17701,19 +17837,10 @@ function RouteComponent() {
17701
17837
  );
17702
17838
  }
17703
17839
 
17704
- return (
17705
- <div className="space-y-4 p-6">
17706
- <h1 className="text-2xl font-semibold">Dashboard</h1>
17707
- <p>Welcome {displayName}</p>
17708
- {{#if (or (eq api "orpc") (eq api "trpc"))}}
17709
- <p>API: {privateData.data?.message}</p>
17710
- {{/if}}
17711
- <UserButton />
17712
- </div>
17713
- );
17840
+ return <Outlet />;
17714
17841
  }
17715
17842
  `],
17716
- ["auth/clerk/web/react/tanstack-start/src/routes/dashboard.tsx.hbs", `{{#if (eq api "trpc")}}
17843
+ ["auth/clerk/web/react/tanstack-start/src/routes/_auth/dashboard.tsx.hbs", `{{#if (eq api "trpc")}}
17717
17844
  import { useTRPC } from "@/utils/trpc";
17718
17845
  import { useQuery } from "@tanstack/react-query";
17719
17846
  {{/if}}
@@ -17721,10 +17848,10 @@ import { useQuery } from "@tanstack/react-query";
17721
17848
  import { useQuery } from "@tanstack/react-query";
17722
17849
  import { orpc } from "@/utils/orpc";
17723
17850
  {{/if}}
17724
- import { SignInButton, UserButton, useUser } from "@clerk/tanstack-react-start";
17851
+ import { UserButton, useUser } from "@clerk/tanstack-react-start";
17725
17852
  import { createFileRoute } from "@tanstack/react-router";
17726
17853
 
17727
- export const Route = createFileRoute("/dashboard")({
17854
+ export const Route = createFileRoute("/_auth/dashboard")({
17728
17855
  component: RouteComponent,
17729
17856
  });
17730
17857
 
@@ -17752,6 +17879,28 @@ function RouteComponent() {
17752
17879
  });
17753
17880
  {{/if}}
17754
17881
 
17882
+ return (
17883
+ <div className="space-y-4 p-6">
17884
+ <h1 className="text-2xl font-semibold">Dashboard</h1>
17885
+ <p>Welcome {displayName}</p>
17886
+ {{#if (or (eq api "orpc") (eq api "trpc"))}}
17887
+ <p>API: {privateData.data?.message}</p>
17888
+ {{/if}}
17889
+ <UserButton />
17890
+ </div>
17891
+ );
17892
+ }
17893
+ `],
17894
+ ["auth/clerk/web/react/tanstack-start/src/routes/_auth/route.tsx.hbs", `import { SignInButton, useUser } from "@clerk/tanstack-react-start";
17895
+ import { Outlet, createFileRoute } from "@tanstack/react-router";
17896
+
17897
+ export const Route = createFileRoute("/_auth")({
17898
+ component: AuthLayout,
17899
+ });
17900
+
17901
+ function AuthLayout() {
17902
+ const user = useUser();
17903
+
17755
17904
  if (!user.isLoaded) {
17756
17905
  return <div className="p-6">Loading...</div>;
17757
17906
  }
@@ -17764,16 +17913,7 @@ function RouteComponent() {
17764
17913
  );
17765
17914
  }
17766
17915
 
17767
- return (
17768
- <div className="space-y-4 p-6">
17769
- <h1 className="text-2xl font-semibold">Dashboard</h1>
17770
- <p>Welcome {displayName}</p>
17771
- {{#if (or (eq api "orpc") (eq api "trpc"))}}
17772
- <p>API: {privateData.data?.message}</p>
17773
- {{/if}}
17774
- <UserButton />
17775
- </div>
17776
- );
17916
+ return <Outlet />;
17777
17917
  }
17778
17918
  `],
17779
17919
  ["auth/clerk/web/react/tanstack-start/src/start.ts.hbs", `import { clerkMiddleware } from '@clerk/tanstack-react-start/server'
@@ -27695,6 +27835,16 @@ export function useColorScheme() {
27695
27835
  const { getDefaultConfig } = require("expo/metro-config");
27696
27836
 
27697
27837
  const config = getDefaultConfig(__dirname);
27838
+ {{#if (or (eq webDeploy "cloudflare") (eq serverDeploy "cloudflare"))}}
27839
+ // Alchemy writes runtime state here; block it to avoid Metro refresh loops.
27840
+ const blockList = config.resolver.blockList ?? [];
27841
+ const blockListPatterns = Array.isArray(blockList) ? blockList : [blockList];
27842
+
27843
+ config.resolver.blockList = [
27844
+ ...blockListPatterns,
27845
+ /[/\\\\]packages[/\\\\]infra[/\\\\]\\.alchemy(?:[/\\\\]|$)/,
27846
+ ];
27847
+ {{/if}}
27698
27848
 
27699
27849
  module.exports = config;
27700
27850
  `],
@@ -28996,6 +29146,16 @@ import './unistyles';
28996
29146
  ["frontend/native/unistyles/metro.config.js.hbs", `const { getDefaultConfig } = require("expo/metro-config");
28997
29147
 
28998
29148
  const config = getDefaultConfig(__dirname);
29149
+ {{#if (or (eq webDeploy "cloudflare") (eq serverDeploy "cloudflare"))}}
29150
+ // Alchemy writes runtime state here; block it to avoid Metro refresh loops.
29151
+ const blockList = config.resolver.blockList ?? [];
29152
+ const blockListPatterns = Array.isArray(blockList) ? blockList : [blockList];
29153
+
29154
+ config.resolver.blockList = [
29155
+ ...blockListPatterns,
29156
+ /[/\\\\]packages[/\\\\]infra[/\\\\]\\.alchemy(?:[/\\\\]|$)/,
29157
+ ];
29158
+ {{/if}}
28999
29159
 
29000
29160
  module.exports = config;
29001
29161
  `],
@@ -30113,6 +30273,16 @@ const { wrapWithReanimatedMetroConfig } = require("react-native-reanimated/metro
30113
30273
 
30114
30274
  /** @type {import('expo/metro-config').MetroConfig} */
30115
30275
  const config = getDefaultConfig(__dirname);
30276
+ {{#if (or (eq webDeploy "cloudflare") (eq serverDeploy "cloudflare"))}}
30277
+ // Alchemy writes runtime state here; block it to avoid Metro refresh loops.
30278
+ const blockList = config.resolver.blockList ?? [];
30279
+ const blockListPatterns = Array.isArray(blockList) ? blockList : [blockList];
30280
+
30281
+ config.resolver.blockList = [
30282
+ ...blockListPatterns,
30283
+ /[/\\\\]packages[/\\\\]infra[/\\\\]\\.alchemy(?:[/\\\\]|$)/,
30284
+ ];
30285
+ {{/if}}
30116
30286
 
30117
30287
  const uniwindConfig = withUniwindConfig(wrapWithReanimatedMetroConfig(config), {
30118
30288
  cssEntryFile: "./global.css",
@@ -31971,7 +32141,7 @@ import { getClerkAuthToken } from "@/utils/clerk-auth";
31971
32141
  {{/if}}
31972
32142
  {{else if (eq api "orpc")}}
31973
32143
  import { setupRouterSsrQueryIntegration } from "@tanstack/react-router-ssr-query";
31974
- import { orpc, queryClient } from "./utils/orpc";
32144
+ import { createQueryClient, orpc } from "./utils/orpc";
31975
32145
  {{/if}}
31976
32146
  {{/if}}
31977
32147
 
@@ -32011,19 +32181,23 @@ export function getRouter() {
32011
32181
  }
32012
32182
  {{else}}
32013
32183
  {{#if (eq api "trpc")}}
32014
- export const queryClient = new QueryClient({
32015
- queryCache: new QueryCache({
32016
- onError: (error, query) => {
32017
- toast.error(error.message, {
32018
- action: {
32019
- label: "retry",
32020
- onClick: query.invalidate,
32021
- },
32022
- });
32023
- },
32024
- }),
32025
- defaultOptions: { queries: { staleTime: 60 * 1000 } },
32026
- });
32184
+ function createQueryClient() {
32185
+ return new QueryClient({
32186
+ queryCache: new QueryCache({
32187
+ onError: (error, query) => {
32188
+ toast.error(error.message, {
32189
+ action: {
32190
+ label: "retry",
32191
+ onClick: () => {
32192
+ query.invalidate();
32193
+ },
32194
+ },
32195
+ });
32196
+ },
32197
+ }),
32198
+ defaultOptions: { queries: { staleTime: 60 * 1000 } },
32199
+ });
32200
+ }
32027
32201
 
32028
32202
  const trpcClient = createTRPCClient<AppRouter>({
32029
32203
  links: [
@@ -32046,15 +32220,20 @@ const trpcClient = createTRPCClient<AppRouter>({
32046
32220
  }),
32047
32221
  ],
32048
32222
  });
32049
-
32050
- const trpc = createTRPCOptionsProxy({
32051
- client: trpcClient,
32052
- queryClient: queryClient,
32053
- });
32054
32223
  {{else if (eq api "orpc")}}
32055
32224
  {{/if}}
32056
32225
 
32057
32226
  export const getRouter = () => {
32227
+ {{#if (eq api "trpc")}}
32228
+ const queryClient = createQueryClient();
32229
+ const trpc = createTRPCOptionsProxy({
32230
+ client: trpcClient,
32231
+ queryClient,
32232
+ });
32233
+ {{else if (eq api "orpc")}}
32234
+ const queryClient = createQueryClient();
32235
+ {{/if}}
32236
+
32058
32237
  const router = createTanStackRouter({
32059
32238
  routeTree,
32060
32239
  scrollRestoration: true,
@@ -33721,6 +33900,53 @@ const db = await D1Database("database", {
33721
33900
  });
33722
33901
  {{/if}}
33723
33902
 
33903
+ {{#if (eq serverDeploy "cloudflare")}}
33904
+ export const server = await Worker("server", {
33905
+ cwd: "../../apps/server",
33906
+ entrypoint: "src/index.ts",
33907
+ compatibility: "node",
33908
+ url: true,
33909
+ bindings: {
33910
+ {{#if (eq dbSetup "d1")}}
33911
+ DB: db,
33912
+ {{else if (ne database "none")}}
33913
+ DATABASE_URL: alchemy.secret.env.DATABASE_URL!,
33914
+ {{/if}}
33915
+ CORS_ORIGIN: alchemy.env.CORS_ORIGIN!,
33916
+ {{#if (eq auth "better-auth")}}
33917
+ BETTER_AUTH_SECRET: alchemy.secret.env.BETTER_AUTH_SECRET!,
33918
+ BETTER_AUTH_URL: alchemy.env.BETTER_AUTH_URL!,
33919
+ {{/if}}
33920
+ {{#if (eq auth "clerk")}}
33921
+ CLERK_SECRET_KEY: alchemy.secret.env.CLERK_SECRET_KEY!,
33922
+ {{#if (and (ne api "none") (or (eq backend "self") (eq backend "hono") (eq backend "elysia")))}}
33923
+ CLERK_PUBLISHABLE_KEY: alchemy.env.CLERK_PUBLISHABLE_KEY!,
33924
+ {{/if}}
33925
+ {{/if}}
33926
+ {{#if (includes examples "ai")}}
33927
+ GOOGLE_GENERATIVE_AI_API_KEY: alchemy.secret.env.GOOGLE_GENERATIVE_AI_API_KEY!,
33928
+ {{/if}}
33929
+ {{#if (eq payments "polar")}}
33930
+ POLAR_ACCESS_TOKEN: alchemy.secret.env.POLAR_ACCESS_TOKEN!,
33931
+ POLAR_SUCCESS_URL: alchemy.env.POLAR_SUCCESS_URL!,
33932
+ {{/if}}
33933
+ {{#if (eq dbSetup "turso")}}
33934
+ DATABASE_AUTH_TOKEN: alchemy.secret.env.DATABASE_AUTH_TOKEN!,
33935
+ {{/if}}
33936
+ {{#if (eq database "mysql")}}
33937
+ {{#if (eq orm "drizzle")}}
33938
+ DATABASE_HOST: alchemy.env.DATABASE_HOST!,
33939
+ DATABASE_USERNAME: alchemy.env.DATABASE_USERNAME!,
33940
+ DATABASE_PASSWORD: alchemy.secret.env.DATABASE_PASSWORD!,
33941
+ {{/if}}
33942
+ {{/if}}
33943
+ },
33944
+ dev: {
33945
+ port: 3000,
33946
+ },
33947
+ });
33948
+ {{/if}}
33949
+
33724
33950
  {{#if (eq webDeploy "cloudflare")}}
33725
33951
  {{#if (includes frontend "next")}}
33726
33952
  export const web = await Nextjs("web", {
@@ -33732,8 +33958,12 @@ export const web = await Nextjs("web", {
33732
33958
  NEXT_PUBLIC_CONVEX_SITE_URL: alchemy.env.NEXT_PUBLIC_CONVEX_SITE_URL!,
33733
33959
  {{/if}}
33734
33960
  {{else if (ne backend "self")}}
33961
+ {{#if (eq serverDeploy "cloudflare")}}
33962
+ NEXT_PUBLIC_SERVER_URL: server.url!,
33963
+ {{else}}
33735
33964
  NEXT_PUBLIC_SERVER_URL: alchemy.env.NEXT_PUBLIC_SERVER_URL!,
33736
33965
  {{/if}}
33966
+ {{/if}}
33737
33967
  {{#if (eq dbSetup "d1")}}
33738
33968
  DB: db,
33739
33969
  {{else if (ne database "none")}}
@@ -33786,8 +34016,12 @@ export const web = await Nuxt("web", {
33786
34016
  NUXT_PUBLIC_CONVEX_SITE_URL: alchemy.env.NUXT_PUBLIC_CONVEX_SITE_URL!,
33787
34017
  {{/if}}
33788
34018
  {{else if (ne backend "self")}}
34019
+ {{#if (eq serverDeploy "cloudflare")}}
34020
+ NUXT_PUBLIC_SERVER_URL: server.url!,
34021
+ {{else}}
33789
34022
  NUXT_PUBLIC_SERVER_URL: alchemy.env.NUXT_PUBLIC_SERVER_URL!,
33790
34023
  {{/if}}
34024
+ {{/if}}
33791
34025
  {{#if (eq backend "self")}}
33792
34026
  {{#if (eq dbSetup "d1")}}
33793
34027
  DB: db,
@@ -33837,8 +34071,12 @@ export const web = await SvelteKit("web", {
33837
34071
  PUBLIC_CONVEX_SITE_URL: alchemy.env.PUBLIC_CONVEX_SITE_URL!,
33838
34072
  {{/if}}
33839
34073
  {{else if (ne backend "self")}}
34074
+ {{#if (eq serverDeploy "cloudflare")}}
34075
+ PUBLIC_SERVER_URL: server.url!,
34076
+ {{else}}
33840
34077
  PUBLIC_SERVER_URL: alchemy.env.PUBLIC_SERVER_URL!,
33841
34078
  {{/if}}
34079
+ {{/if}}
33842
34080
  {{#if (eq backend "self")}}
33843
34081
  {{#if (eq dbSetup "d1")}}
33844
34082
  DB: db,
@@ -33883,8 +34121,12 @@ export const web = await TanStackStart("web", {
33883
34121
  VITE_CONVEX_SITE_URL: alchemy.env.VITE_CONVEX_SITE_URL!,
33884
34122
  {{/if}}
33885
34123
  {{else if (ne backend "self")}}
34124
+ {{#if (eq serverDeploy "cloudflare")}}
34125
+ VITE_SERVER_URL: server.url!,
34126
+ {{else}}
33886
34127
  VITE_SERVER_URL: alchemy.env.VITE_SERVER_URL!,
33887
34128
  {{/if}}
34129
+ {{/if}}
33888
34130
  {{#if (eq dbSetup "d1")}}
33889
34131
  DB: db,
33890
34132
  {{else if (ne database "none")}}
@@ -33933,8 +34175,12 @@ export const web = await Vite("web", {
33933
34175
  VITE_CONVEX_SITE_URL: alchemy.env.VITE_CONVEX_SITE_URL!,
33934
34176
  {{/if}}
33935
34177
  {{else if (ne backend "self")}}
34178
+ {{#if (eq serverDeploy "cloudflare")}}
34179
+ VITE_SERVER_URL: server.url!,
34180
+ {{else}}
33936
34181
  VITE_SERVER_URL: alchemy.env.VITE_SERVER_URL!,
33937
34182
  {{/if}}
34183
+ {{/if}}
33938
34184
  }
33939
34185
  });
33940
34186
  {{else if (includes frontend "react-router")}}
@@ -33947,8 +34193,12 @@ export const web = await ReactRouter("web", {
33947
34193
  VITE_CONVEX_SITE_URL: alchemy.env.VITE_CONVEX_SITE_URL!,
33948
34194
  {{/if}}
33949
34195
  {{else if (ne backend "self")}}
34196
+ {{#if (eq serverDeploy "cloudflare")}}
34197
+ VITE_SERVER_URL: server.url!,
34198
+ {{else}}
33950
34199
  VITE_SERVER_URL: alchemy.env.VITE_SERVER_URL!,
33951
34200
  {{/if}}
34201
+ {{/if}}
33952
34202
  }
33953
34203
  });
33954
34204
  {{else if (includes frontend "solid")}}
@@ -33962,8 +34212,12 @@ export const web = await Vite("web", {
33962
34212
  VITE_CONVEX_SITE_URL: alchemy.env.VITE_CONVEX_SITE_URL!,
33963
34213
  {{/if}}
33964
34214
  {{else if (ne backend "self")}}
34215
+ {{#if (eq serverDeploy "cloudflare")}}
34216
+ VITE_SERVER_URL: server.url!,
34217
+ {{else}}
33965
34218
  VITE_SERVER_URL: alchemy.env.VITE_SERVER_URL!,
33966
34219
  {{/if}}
34220
+ {{/if}}
33967
34221
  }
33968
34222
  });
33969
34223
  {{else if (includes frontend "astro")}}
@@ -33976,8 +34230,12 @@ export const web = await Astro("web", {
33976
34230
  {{/if}}
33977
34231
  bindings: {
33978
34232
  {{#if (ne backend "self")}}
34233
+ {{#if (eq serverDeploy "cloudflare")}}
34234
+ PUBLIC_SERVER_URL: server.url!,
34235
+ {{else}}
33979
34236
  PUBLIC_SERVER_URL: alchemy.env.PUBLIC_SERVER_URL!,
33980
34237
  {{/if}}
34238
+ {{/if}}
33981
34239
  {{#if (eq backend "self")}}
33982
34240
  {{#if (eq dbSetup "d1")}}
33983
34241
  DB: db,
@@ -34009,52 +34267,6 @@ export const web = await Astro("web", {
34009
34267
  {{/if}}
34010
34268
  {{/if}}
34011
34269
 
34012
- {{#if (eq serverDeploy "cloudflare")}}
34013
- export const server = await Worker("server", {
34014
- cwd: "../../apps/server",
34015
- entrypoint: "src/index.ts",
34016
- compatibility: "node",
34017
- bindings: {
34018
- {{#if (eq dbSetup "d1")}}
34019
- DB: db,
34020
- {{else if (ne database "none")}}
34021
- DATABASE_URL: alchemy.secret.env.DATABASE_URL!,
34022
- {{/if}}
34023
- CORS_ORIGIN: alchemy.env.CORS_ORIGIN!,
34024
- {{#if (eq auth "better-auth")}}
34025
- BETTER_AUTH_SECRET: alchemy.secret.env.BETTER_AUTH_SECRET!,
34026
- BETTER_AUTH_URL: alchemy.env.BETTER_AUTH_URL!,
34027
- {{/if}}
34028
- {{#if (eq auth "clerk")}}
34029
- CLERK_SECRET_KEY: alchemy.secret.env.CLERK_SECRET_KEY!,
34030
- {{#if (and (ne api "none") (or (eq backend "self") (eq backend "hono") (eq backend "elysia")))}}
34031
- CLERK_PUBLISHABLE_KEY: alchemy.env.CLERK_PUBLISHABLE_KEY!,
34032
- {{/if}}
34033
- {{/if}}
34034
- {{#if (includes examples "ai")}}
34035
- GOOGLE_GENERATIVE_AI_API_KEY: alchemy.secret.env.GOOGLE_GENERATIVE_AI_API_KEY!,
34036
- {{/if}}
34037
- {{#if (eq payments "polar")}}
34038
- POLAR_ACCESS_TOKEN: alchemy.secret.env.POLAR_ACCESS_TOKEN!,
34039
- POLAR_SUCCESS_URL: alchemy.env.POLAR_SUCCESS_URL!,
34040
- {{/if}}
34041
- {{#if (eq dbSetup "turso")}}
34042
- DATABASE_AUTH_TOKEN: alchemy.secret.env.DATABASE_AUTH_TOKEN!,
34043
- {{/if}}
34044
- {{#if (eq database "mysql")}}
34045
- {{#if (eq orm "drizzle")}}
34046
- DATABASE_HOST: alchemy.env.DATABASE_HOST!,
34047
- DATABASE_USERNAME: alchemy.env.DATABASE_USERNAME!,
34048
- DATABASE_PASSWORD: alchemy.secret.env.DATABASE_PASSWORD!,
34049
- {{/if}}
34050
- {{/if}}
34051
- },
34052
- dev: {
34053
- port: 3000,
34054
- },
34055
- });
34056
- {{/if}}
34057
-
34058
34270
  {{#if (and (eq webDeploy "cloudflare") (eq serverDeploy "cloudflare"))}}
34059
34271
  console.log(\`Web -> \${web.url}\`);
34060
34272
  console.log(\`Server -> \${server.url}\`);
@@ -35085,7 +35297,7 @@ function SuccessPage() {
35085
35297
  </div>
35086
35298
  `]
35087
35299
  ]);
35088
- const TEMPLATE_COUNT = 475;
35300
+ const TEMPLATE_COUNT = 483;
35089
35301
  //#endregion
35090
35302
  export { EMBEDDED_TEMPLATES, GeneratorError, Handlebars, TEMPLATE_COUNT, VirtualFileSystem, dependencyVersionMap, generate, generateReproducibleCommand, isBinaryFile, processAddonTemplates, processAddonsDeps, processFileContent, processTemplateString, transformFilename, writeBtsConfigToVfs };
35091
35303