Compare commits
130 Commits
dev/fix-we
...
cloudflare
Author | SHA1 | Date | |
---|---|---|---|
|
2a6e322c0a | ||
|
e3ac4a0a29 | ||
|
b0a065ced9 | ||
|
ad1cbedb56 | ||
|
e3f44a85a5 | ||
|
2faedc2043 | ||
|
0c415ee24b | ||
|
658409cfbd | ||
|
613bbd0d78 | ||
|
5f14259197 | ||
|
b4dab95c04 | ||
|
8221f1753f | ||
|
18691030e7 | ||
|
7aa7cb5603 | ||
|
ca30f95027 | ||
|
d747683f82 | ||
|
b55613b471 | ||
|
47679ab91e | ||
|
f468638f49 | ||
|
35ddf5e08e | ||
|
1f7c38f9f5 | ||
|
63dd4e52fb | ||
|
200a9963f7 | ||
|
0da8f7d335 | ||
|
004edeecea | ||
|
6bb12a2d86 | ||
|
97654d97ea | ||
|
aa2e025270 | ||
|
11bfcb731d | ||
|
62eb4124be | ||
|
d7cc9b956d | ||
|
22d68c005a | ||
|
70446d10b3 | ||
|
313c783dbd | ||
|
cc56f9d729 | ||
|
e5569dabd1 | ||
|
813d8ea0bb | ||
|
c67b804f4f | ||
|
a44e4a669c | ||
|
da4b018e8d | ||
|
b838ddc293 | ||
|
8e63af3e7f | ||
|
1e2e4d77f7 | ||
|
e94625ce4e | ||
|
2153cf6771 | ||
|
0164c833db | ||
|
5d50135ed6 | ||
|
cbfe5e433d | ||
|
7ab7d2d504 | ||
|
522d8de4ee | ||
|
0739c717d8 | ||
|
71b9807433 | ||
|
8a72fb2409 | ||
|
e00c22d0fe | ||
|
bd8ccf4cf3 | ||
|
d0aef4b7d4 | ||
|
c006ee750d | ||
|
19a6c4d994 | ||
|
86f13a1748 | ||
|
745ba457df | ||
|
beb53639a3 | ||
|
65fb8722bc | ||
|
160a7eb929 | ||
|
c3d82d9183 | ||
|
767351c5cd | ||
|
fd3c82baaf | ||
|
168eae946f | ||
|
69390fed70 | ||
|
2cb041beb1 | ||
|
3645cf5773 | ||
|
c6ad6d0ad5 | ||
|
53ab869f07 | ||
|
e0f408fb07 | ||
|
1216732a55 | ||
|
4c6fddf99d | ||
|
90d5db88ab | ||
|
af5a3265a6 | ||
|
ec8ce54824 | ||
|
f4d8a09ab6 | ||
|
3b741b3b98 | ||
|
b07be5fab4 | ||
|
a22a5def4d | ||
|
d190bcb358 | ||
|
7f1fe23407 | ||
|
05a7de4599 | ||
|
c098300481 | ||
|
e7240db823 | ||
|
a4390d433b | ||
|
ae49d06cf4 | ||
|
6a448825a6 | ||
|
4d60d48212 | ||
|
26a88eb2f0 | ||
|
c5d08a9846 | ||
|
f5b4ed2859 | ||
|
b88aa9c1f5 | ||
|
593333c3dd | ||
|
f3b6603db7 | ||
|
9cb559a48d | ||
|
c3392320b3 | ||
|
708fac652f | ||
|
ec124640f1 | ||
|
862132d8eb | ||
|
bf11c143fe | ||
|
6cfc76d621 | ||
|
d935bcff76 | ||
|
a727a31e2f | ||
|
81cfc5f6b3 | ||
|
8e8291c325 | ||
|
6ff2ea6845 | ||
|
b6836db12d | ||
|
5f435b9614 | ||
|
9b03f6201f | ||
|
111f00adaa | ||
|
002d2090c2 | ||
|
c3913dbc88 | ||
|
9b68e3095e | ||
|
2fb627a6e9 | ||
|
f11e37374b | ||
|
3560616b52 | ||
|
80219fa10b | ||
|
a62abbf399 | ||
|
dd95dece87 | ||
|
c938122f7e | ||
|
3887da26d0 | ||
|
7af193f770 | ||
|
d6093394d8 | ||
|
f1537e305a | ||
|
1847ef4363 | ||
|
0fd695c8bc | ||
|
ae083a7992 |
7483
cloudflare-env.d.ts
vendored
Normal file
7483
cloudflare-env.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
dev.vars.example
Normal file
1
dev.vars.example
Normal file
@ -0,0 +1 @@
|
||||
NEXTJS_ENV=development
|
@ -18,6 +18,18 @@ const nextConfig: NextConfig = {
|
||||
// removeConsole: process.env.NODE_ENV === 'production',
|
||||
},
|
||||
|
||||
// https://github.com/vercel/next.js/discussions/50177#discussioncomment-6006702
|
||||
// fix build error: Module build failed: UnhandledSchemeError:
|
||||
// Reading from "cloudflare:sockets" is not handled by plugins (Unhandled scheme).
|
||||
webpack: (config, { webpack }) => {
|
||||
config.plugins.push(
|
||||
new webpack.IgnorePlugin({
|
||||
resourceRegExp: /^pg-native$|^cloudflare:sockets$/,
|
||||
})
|
||||
);
|
||||
return config;
|
||||
},
|
||||
|
||||
images: {
|
||||
// https://vercel.com/docs/image-optimization/managing-image-optimization-costs#minimizing-image-optimization-costs
|
||||
// https://nextjs.org/docs/app/api-reference/components/image#unoptimized
|
||||
@ -70,3 +82,9 @@ const withNextIntl = createNextIntlPlugin();
|
||||
const withMDX = createMDX();
|
||||
|
||||
export default withMDX(withNextIntl(nextConfig));
|
||||
|
||||
// https://opennext.js.org/cloudflare/get-started#12-develop-locally
|
||||
import { initOpenNextCloudflareForDev } from '@opennextjs/cloudflare';
|
||||
|
||||
// during local development, to access in any of your server code, local versions of Cloudflare bindings
|
||||
initOpenNextCloudflareForDev();
|
||||
|
6
open-next.config.ts
Normal file
6
open-next.config.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { defineCloudflareConfig } from "@opennextjs/cloudflare";
|
||||
|
||||
|
||||
export default defineCloudflareConfig({
|
||||
|
||||
});
|
@ -4,6 +4,7 @@
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"cf-dev": "next dev -p 8787",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"postinstall": "fumadocs-mdx",
|
||||
@ -111,6 +112,7 @@
|
||||
"next-intl": "^4.0.0",
|
||||
"next-safe-action": "^7.10.4",
|
||||
"next-themes": "^0.4.4",
|
||||
"pg": "^8.16.0",
|
||||
"nuqs": "^2.5.1",
|
||||
"postgres": "^3.4.5",
|
||||
"radix-ui": "^1.4.2",
|
||||
@ -143,6 +145,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "1.9.4",
|
||||
"@opennextjs/cloudflare": "^1.6.5",
|
||||
"@tailwindcss/postcss": "^4.0.14",
|
||||
"@tanstack/eslint-plugin-query": "^5.83.1",
|
||||
"@types/mdx": "^2.0.13",
|
||||
@ -157,6 +160,7 @@
|
||||
"react-email": "3.0.7",
|
||||
"tailwindcss": "^4.0.14",
|
||||
"tsx": "^4.19.3",
|
||||
"typescript": "^5.8.3"
|
||||
"typescript": "^5.8.3",
|
||||
"wrangler": "^4.28.1"
|
||||
}
|
||||
}
|
||||
|
4299
pnpm-lock.yaml
generated
4299
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
2
public/_headers
Normal file
2
public/_headers
Normal file
@ -0,0 +1,2 @@
|
||||
/_next/static/*
|
||||
Cache-Control: public,max-age=31536000,immutable
|
@ -2,17 +2,23 @@
|
||||
* Connect to PostgreSQL Database (Supabase/Neon/Local PostgreSQL)
|
||||
* https://orm.drizzle.team/docs/tutorials/drizzle-with-supabase
|
||||
*/
|
||||
import { drizzle } from 'drizzle-orm/postgres-js';
|
||||
import postgres from 'postgres';
|
||||
import { getCloudflareContext } from '@opennextjs/cloudflare';
|
||||
import { drizzle } from 'drizzle-orm/node-postgres';
|
||||
import { Pool } from 'pg';
|
||||
import * as schema from './schema';
|
||||
|
||||
let db: ReturnType<typeof drizzle> | null = null;
|
||||
|
||||
// https://opennext.js.org/cloudflare/howtos/db#postgresql
|
||||
export async function getDb() {
|
||||
if (db) return db;
|
||||
const connectionString = process.env.DATABASE_URL!;
|
||||
const client = postgres(connectionString, { prepare: false });
|
||||
db = drizzle(client, { schema });
|
||||
const { env } = await getCloudflareContext({ async: true });
|
||||
const pool = new Pool({
|
||||
connectionString: env.HYPERDRIVE.connectionString,
|
||||
// You don't want to reuse the same connection for multiple requests
|
||||
maxUses: 1,
|
||||
});
|
||||
db = drizzle({ client: pool, schema });
|
||||
return db;
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,13 @@ export class StripeProvider implements PaymentProvider {
|
||||
}
|
||||
|
||||
// Initialize Stripe without specifying apiVersion to use default/latest version
|
||||
this.stripe = new Stripe(apiKey);
|
||||
// https://opennext.js.org/cloudflare/howtos/stripeAPI
|
||||
// When creating a Stripe object, the default http client implementation is based on
|
||||
// node:https which is not implemented on Workers.
|
||||
this.stripe = new Stripe(apiKey, {
|
||||
// Cloudflare Workers use the Fetch API for their API requests.
|
||||
httpClient: Stripe.createFetchHttpClient(),
|
||||
});
|
||||
this.webhookSecret = webhookSecret;
|
||||
}
|
||||
|
||||
|
84
wrangler.jsonc
Normal file
84
wrangler.jsonc
Normal file
@ -0,0 +1,84 @@
|
||||
/**
|
||||
* For more details on how to configure Wrangler, refer to:
|
||||
* https://developers.cloudflare.com/workers/wrangler/configuration/
|
||||
*/
|
||||
{
|
||||
"$schema": "node_modules/wrangler/config-schema.json",
|
||||
"main": ".open-next/worker.js",
|
||||
"name": "mksaas-template",
|
||||
"compatibility_date": "2024-12-30",
|
||||
"compatibility_flags": [
|
||||
// Enable Node.js API
|
||||
// see https://developers.cloudflare.com/workers/configuration/compatibility-flags/#nodejs-compatibility-flag
|
||||
"nodejs_compat",
|
||||
// This also enables nodejs_compat_v2 as long as compatibility date is 2024-09-23 or later.
|
||||
// https://developers.cloudflare.com/workers/configuration/compatibility-dates/#nodejs-compatibility-flag
|
||||
// Enable improved Node.js API with polyfills and native code
|
||||
// see https://blog.cloudflare.com/zh-cn/more-npm-packages-on-cloudflare-workers-combining-polyfills-and-native-code/
|
||||
// "nodejs_compat_v2",
|
||||
// Enable auto-populating process.env
|
||||
// see https://developers.cloudflare.com/workers/configuration/compatibility-flags/#enable-auto-populating-processenv
|
||||
"nodejs_compat_populate_process_env",
|
||||
// Allow to fetch URLs in your app
|
||||
// see https://developers.cloudflare.com/workers/configuration/compatibility-flags/#global-fetch-strictly-public
|
||||
"global_fetch_strictly_public"
|
||||
],
|
||||
// Minification helps to keep the Worker bundle size down and improve start up time.
|
||||
"minify": true,
|
||||
|
||||
// Enables Workers Trace Events Logpush for a Worker
|
||||
"logpush": true,
|
||||
|
||||
// https://developers.cloudflare.com/workers/wrangler/configuration/#top-level-only-keys
|
||||
// Whether Wrangler should keep variables configured in the dashboard on deploy
|
||||
"keep_vars": true,
|
||||
|
||||
"assets": {
|
||||
"binding": "ASSETS",
|
||||
"directory": ".open-next/assets"
|
||||
},
|
||||
|
||||
// https://developers.cloudflare.com/workers/wrangler/configuration/#observability
|
||||
"observability": {
|
||||
"enabled": true
|
||||
},
|
||||
|
||||
/**
|
||||
* Smart Placement
|
||||
* Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement
|
||||
*/
|
||||
// "placement": { "mode": "smart" },
|
||||
|
||||
/**
|
||||
* Bindings
|
||||
* Bindings allow your Worker to interact with resources on the Cloudflare Developer Platform, including
|
||||
* databases, object storage, AI inference, real-time communication and more.
|
||||
* https://developers.cloudflare.com/workers/runtime-apis/bindings/
|
||||
*/
|
||||
|
||||
/**
|
||||
* Hyperdrive
|
||||
* https://opennext.js.org/cloudflare/howtos/db#hyperdrive-example
|
||||
* https://developers.cloudflare.com/workers/tutorials/postgres/#8-use-hyperdrive-to-accelerate-queries
|
||||
*/
|
||||
"hyperdrive": [
|
||||
{
|
||||
"binding": "HYPERDRIVE",
|
||||
"id": "8ba4508b28cf42f987f3533c1f09433c",
|
||||
"localConnectionString": "postgresql://postgres:postgres@localhost:5432/postgres"
|
||||
}
|
||||
],
|
||||
|
||||
/**
|
||||
* Environment Variables
|
||||
* https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
|
||||
*/
|
||||
"vars": {},
|
||||
|
||||
/**
|
||||
* Note: Use secrets to store sensitive data.
|
||||
* https://developers.cloudflare.com/workers/configuration/secrets/
|
||||
*/
|
||||
|
||||
"kv_namespaces": []
|
||||
}
|
Loading…
Reference in New Issue
Block a user