feat: local debugging with wrangler

Signed-off-by: Tom Plant <[email protected]>
This commit is contained in:
Tom Plant committed 2024-01-14 08:12:02 +00:00
1 parent 1e183247cf
commit 3b20472433
8 files changed
+6165 -101

No files matched your search

+2
View File
@@ -36,3 +36,5 @@ next-env.d.ts
.terraform/
terraform.tfstate*
/.wrangler
Vendored
+9
View File
@@ -0,0 +1,9 @@
declare global {
namespace NodeJS {
interface ProcessEnv {
UPTIMEFLARE_STATE: KVNamespace;
}
}
}
export {};
+12
View File
@@ -4,3 +4,15 @@ const nextConfig = {
}
module.exports = nextConfig
if (process.env.NODE_ENV === 'development') {
const { setupDevBindings } = require('@cloudflare/next-on-pages/next-dev')
setupDevBindings({
bindings: {
UPTIMEFLARE_STATE: {
type: 'kv',
id: 'UPTIMEFLARE_STATE'
}
}
})
}
+6133 -99
View File
File diff suppressed because it is too large. Load diff
+2
View File
@@ -4,6 +4,7 @@
"private": true,
"scripts": {
"dev": "next dev",
"preview": "npx @cloudflare/next-on-pages && wrangler pages dev .vercel/output/static --compatibility-flag nodejs_compat --kv UPTIMEFLARE_STATE",
"build": "next build",
"start": "next start",
"lint": "next lint"
@@ -25,6 +26,7 @@
"react-dom": "^18"
},
"devDependencies": {
"@cloudflare/next-on-pages": "^1.8.5",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
+2 -1
View File
@@ -15,7 +15,8 @@
"incremental": true,
"paths": {
"@/*": ["./*"]
}
},
"types": ["@cloudflare/workers-types"]
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules", "worker/**/*.ts"]
+1 -1
View File
@@ -5,7 +5,7 @@
"scripts": {
"vercel-build": "next build",
"deploy": "wrangler deploy",
"dev": "wrangler dev",
"dev": "wrangler dev --config wrangler-dev.toml --test-scheduled --persist-to ../.wrangler/state",
"start": "wrangler dev"
},
"devDependencies": {
+4
View File
@@ -0,0 +1,4 @@
name = "uptimeflare_worker"
main = "src/index.ts"
compatibility_date = "2023-11-08"
kv_namespaces = [{ binding = "UPTIMEFLARE_STATE", id = "UPTIMEFLARE_STATE" }]