Initial commit

This commit is contained in:
2025-09-28 08:50:15 -07:00
committed by GitHub
commit f4d22df46b
7 changed files with 177 additions and 0 deletions

17
.github/workflows/auto-name.yml vendored Normal file
View File

@@ -0,0 +1,17 @@
on: push
permissions: write-all
jobs:
j:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
n=${GITHUB_REPOSITORY#*/};n=$(echo $n|tr A-Z a-z)
jq ".name=\"$n\"" package.json>p.json && mv p.json package.json
sed -i "s/^name *=.*$/name = \"$n\"/" wrangler.toml
git diff --quiet || {
git config user.email a@a.a
git config user.name a
git commit -am update
git push
}

42
.github/workflows/bind-everything.yml vendored Normal file
View File

@@ -0,0 +1,42 @@
on:
push:
workflow_dispatch:
permissions:
contents: write
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Dependencies
run: npm install -g wrangler
- name: Fetch Cloudflare Account ID & Sync Bindings
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
run: |
export CLOUDFLARE_ACCOUNT_ID=$(curl -sX GET "https://api.cloudflare.com/client/v4/accounts" -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" -H "Content-Type:application/json" | jq -r '.result[0].id')
wrangler d1 list --json | jq -c '.[]' | while read -r db; do
id=$(jq -r .uuid <<< "$db")
if ! grep -q "$id" wrangler.toml; then
name=$(jq -r .name <<< "$db")
binding=$(echo "$name" | tr '[:lower:]-' '[:upper:]_')
printf '\n[[d1_databases]]\nbinding = "%s"\ndatabase_name = "%s"\ndatabase_id = "%s"\n' "$binding" "$name" "$id" >> wrangler.toml
fi
done
- name: Commit and Push Changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "chore: Sync D1 database bindings"
file_pattern: wrangler.toml

11
.github/workflows/deep.yml vendored Normal file
View File

@@ -0,0 +1,11 @@
on:
workflow_dispatch:
push:
jobs:
deploy-cloudflare:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}

22
.gitignore vendored Normal file
View File

@@ -0,0 +1,22 @@
logs
*.log
npm-debug.log
.pnpm-debug.log
node_modules/
jspm_packages/
.npm
.eslintcache
.stylelintcache
.node_repl_history
*.tgz
.cache
out
dist
.temp
.cache
.pnp.*
.dev.vars
!.dev.vars.example
.env
!.env.example
.wrangler/

11
index.js Normal file
View File

@@ -0,0 +1,11 @@
async function fetch(request) {
if (request.method === 'OPTIONS') {
const headers = new Headers()
headers.set('Access-Control-Allow-Origin', '*')
headers.set('Access-Control-Allow-Headers', 'Authorization, Content-Type')
return new Response(null, { headers })
}
return new Response('OK')
}
export default { fetch }

15
package.json Normal file
View File

@@ -0,0 +1,15 @@
{
"name": "workertemplate",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"deploy": "wrangler deploy",
"dev": "wrangler dev",
"start": "wrangler dev"
},
"dependencies": {},
"devDependencies": {
"wrangler": "4.33.*"
}
}

59
wrangler.toml Normal file
View File

@@ -0,0 +1,59 @@
name = "workertemplate"
main = "index.js"
compatibility_date = "2025-09-09"
# compatibility_flags = []
# node_compat = true
# keep_vars = true
# [triggers]
# crons = ["*/5 * * * *"]
# [vars]
# [assets]
# directory = "./public"
# binding = "ASSETS"
# [wasm_modules]
# WASM_PARSER = "./wasm/parser.wasm"
# [text_blobs]
# EMAIL_TEMPLATE = "./templates/welcome.txt"
# [data_blobs]
# BINARY_CHUNK = "./assets/blob.bin"
# [[kv_namespaces]]
# binding = "MY_KV"
# id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# [[r2_buckets]]
# binding = "MY_BUCKET"
# bucket_name = "my-bucket"
# [[d1_databases]]
# binding = "DB"
# database_name = "my-db"
# database_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# [durable_objects]
# bindings = [{ name = "MY_DO", class_name = "MyDurableObject" }]
# [[migrations]]
# tag = "v1"
# new_classes = ["MyDurableObject"]
[[d1_databases]]
binding = "SUNE_PLATFORM_USERS"
database_name = "sune_platform_users"
database_id = "464b291c-90a5-4947-b96b-b1b5aeca1db3"
[[d1_databases]]
binding = "HI"
database_name = "hi"
database_id = "45ee691d-3d0c-42f2-8e3a-35a369444a03"
[[d1_databases]]
binding = "SUNE"
database_name = "sune"
database_id = "140c5f3d-c4d4-4cdf-b520-a23366172971"