Skip to content

Commit 37e4e9a

Browse files
test: switch to cloudflare
1 parent f56a3b7 commit 37e4e9a

File tree

18 files changed

+1951
-420
lines changed

18 files changed

+1951
-420
lines changed

apps/cli/src/utils/bts-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export async function writeBtsConfig(projectConfig: ProjectConfig) {
2525
};
2626

2727
const baseContent = {
28-
$schema: "https://better-t-stack.dev/schema.json",
28+
$schema: "https://r2.better-t-stack.dev/schema.json",
2929
version: btsConfig.version,
3030
createdAt: btsConfig.createdAt,
3131
database: btsConfig.database,

apps/web/instrumentation-client.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1+
// instrumentation-client.js
12
import posthog from "posthog-js";
23

3-
if (process.env.NODE_ENV !== "development") {
4-
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY || "", {
5-
api_host: "/ingest",
6-
ui_host: "https://us.posthog.com",
7-
defaults: "2025-05-24",
8-
capture_exceptions: true, // This enables capturing exceptions using Error Tracking
9-
debug: process.env.NODE_ENV !== "production",
10-
});
11-
}
4+
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY || "", {
5+
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST,
6+
defaults: "2025-05-24",
7+
});

apps/web/next.config.mjs

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,19 @@ const withMDX = createMDX();
55
/** @type {import('next').NextConfig} */
66
const config = {
77
reactStrictMode: true,
8-
// This is required to support PostHog trailing slash API requests
9-
skipTrailingSlashRedirect: true,
10-
experimental: {
11-
reactCompiler: true,
12-
},
138
images: {
149
remotePatterns: [
1510
{ protocol: "https", hostname: "pbs.twimg.com" },
1611
{ protocol: "https", hostname: "abs.twimg.com" },
1712
],
1813
},
19-
async rewrites() {
20-
return [
21-
{
22-
source: "/ingest/static/:path*",
23-
destination: "https://us-assets.i.posthog.com/static/:path*",
24-
},
25-
{
26-
source: "/ingest/:path*",
27-
destination: "https://us.i.posthog.com/:path*",
28-
},
29-
{
30-
source: "/ingest/decide",
31-
destination: "https://us.i.posthog.com/decide",
32-
},
33-
{
34-
source: "/docs/:path*.mdx",
35-
destination: "/llms.mdx/:path*",
36-
},
37-
];
14+
outputFileTracingExcludes: {
15+
"*": ["./**/*.js.map", "./**/*.mjs.map", "./**/*.cjs.map"],
3816
},
3917
};
4018

4119
export default withMDX(config);
20+
21+
import { initOpenNextCloudflareForDev } from "@opennextjs/cloudflare";
22+
23+
initOpenNextCloudflareForDev();

apps/web/open-next.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { defineCloudflareConfig } from "@opennextjs/cloudflare";
2+
3+
export default defineCloudflareConfig();

apps/web/package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@
88
"start": "next start",
99
"check": "biome check --write .",
1010
"postinstall": "fumadocs-mdx",
11-
"deploy": "vercel --prod",
12-
"preview": "vercel dev",
11+
"preview": "opennextjs-cloudflare build && opennextjs-cloudflare preview",
12+
"deploy": "opennextjs-cloudflare build && opennextjs-cloudflare deploy -- --keep-vars",
13+
"cf-typegen": "wrangler types --env-interface CloudflareEnv cloudflare-env.d.ts",
1314
"generate-analytics": "bun scripts/generate-analytics.ts",
1415
"generate-schema": "bun scripts/generate-schema.ts"
1516
},
1617
"dependencies": {
1718
"@better-t-stack/backend": "workspace:*",
1819
"@erquhart/convex-oss-stats": "^0.8.1",
1920
"@number-flow/react": "^0.5.10",
21+
"@opennextjs/cloudflare": "^1.6.3",
2022
"@orama/orama": "^3.1.11",
2123
"@radix-ui/react-dropdown-menu": "^2.1.15",
2224
"babel-plugin-react-compiler": "^19.1.0-rc.2",
@@ -29,7 +31,7 @@
2931
"fumadocs-ui": "15.6.7",
3032
"lucide-react": "^0.536.0",
3133
"motion": "^12.23.12",
32-
"next": "15.4.5",
34+
"next": "15.3.5",
3335
"next-themes": "^0.4.6",
3436
"nuqs": "^2.4.3",
3537
"papaparse": "^5.5.3",
@@ -55,6 +57,7 @@
5557
"postcss": "^8.5.6",
5658
"tailwindcss": "^4.1.11",
5759
"tw-animate-css": "^1.3.6",
58-
"typescript": "^5.9.2"
60+
"typescript": "^5.9.2",
61+
"wrangler": "^4.27.0"
5962
}
6063
}
File renamed without changes.

apps/web/scripts/generate-schema.ts

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import path from "node:path";
2-
import fs from "fs-extra";
1+
import { execSync } from "node:child_process";
2+
import { mkdtempSync, writeFileSync } from "node:fs";
3+
import { tmpdir } from "node:os";
4+
import { join } from "node:path";
35
import {
46
AddonsSchema,
57
APISchema,
@@ -28,7 +30,7 @@ const WEB_DEPLOY_VALUES = WebDeploySchema.options;
2830

2931
const configSchema = {
3032
$schema: "http://json-schema.org/draft-07/schema#",
31-
$id: "https://better-t-stack.dev/schema.json",
33+
$id: "https://r2.better-t-stack.dev/schema.json",
3234
title: "Better-T-Stack Configuration",
3335
description: "Configuration file for Better-T-Stack projects",
3436
type: "object",
@@ -136,14 +138,34 @@ const configSchema = {
136138
};
137139

138140
async function generateSchema() {
139-
const schemaPath = path.join(process.cwd(), "public", "schema.json");
140-
await fs.ensureDir(path.dirname(schemaPath));
141-
await fs.writeFile(
142-
schemaPath,
143-
JSON.stringify(configSchema, null, 2),
144-
"utf-8",
145-
);
146-
console.log("✅ Generated schema.json from shared types package");
141+
try {
142+
console.log("🔄 Generating schema...");
143+
144+
const tempDir = mkdtempSync(join(tmpdir(), "schema-"));
145+
const tempFilePath = join(tempDir, "schema.json");
146+
147+
writeFileSync(tempFilePath, JSON.stringify(configSchema, null, 2));
148+
149+
console.log("📤 Uploading to Cloudflare R2...");
150+
151+
const BUCKET_NAME = "bucket";
152+
const key = "schema.json";
153+
const cmd = `npx wrangler r2 object put "${BUCKET_NAME}/${key}" --file="${tempFilePath}" --remote`;
154+
155+
console.log(`Uploading ${tempFilePath} to r2://${BUCKET_NAME}/${key} ...`);
156+
try {
157+
execSync(cmd, { stdio: "inherit" });
158+
} catch (err) {
159+
console.error("Failed to upload schema:", err);
160+
throw err;
161+
}
162+
163+
console.log("✅ Generated schema.json from shared types package");
164+
console.log("📤 Uploaded to R2 bucket: bucket/schema.json");
165+
} catch (error) {
166+
console.error("❌ Error generating schema:", error);
167+
process.exit(1);
168+
}
147169
}
148170

149171
generateSchema().catch(console.error);

apps/web/src/app/docs-og/[...slug]/route.tsx

Lines changed: 0 additions & 25 deletions
This file was deleted.

apps/web/src/app/docs/[[...slug]]/page.tsx

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
DocsTitle,
88
} from "fumadocs-ui/page";
99
import { notFound } from "next/navigation";
10-
import { LLMCopyButton, ViewOptions } from "@/components/ai/page-actions";
1110
import { source } from "@/lib/source";
1211

1312
export default async function Page(props: {
@@ -21,13 +20,6 @@ export default async function Page(props: {
2120

2221
return (
2322
<DocsPage toc={page.data.toc} full={page.data.full}>
24-
<div className="flex flex-row items-center gap-2 border-b pt-2 pb-6">
25-
<LLMCopyButton markdownUrl={`${page.url}.mdx`} />
26-
<ViewOptions
27-
markdownUrl={`${page.url}.mdx`}
28-
githubUrl={`https://github.com/amanvarshney01/create-better-t-stack/blob/dev/apps/docs/content/docs/${page.path}`}
29-
/>
30-
</div>
3123
<DocsTitle>{page.data.title}</DocsTitle>
3224
<DocsDescription>{page.data.description}</DocsDescription>
3325
<DocsBody>
@@ -49,16 +41,8 @@ export async function generateMetadata({
4941
const { slug = [] } = await params;
5042
const page = source.getPage(slug);
5143
if (!page) notFound();
52-
const image = ["/docs-og", ...slug, "image.png"].join("/");
5344
return {
5445
title: page.data.title,
5546
description: page.data.description,
56-
openGraph: {
57-
images: image,
58-
},
59-
twitter: {
60-
card: "summary_large_image",
61-
images: image,
62-
},
6347
};
6448
}

apps/web/src/app/llms-full.txt/route.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)