From c156188d6ee69d79f75b884b05c56cb3d09e562b Mon Sep 17 00:00:00 2001 From: multipleof4 Date: Tue, 9 Sep 2025 04:56:26 -0700 Subject: [PATCH] Initial commit --- .github/workflows/deep.yml | 11 +++ .gitignore | 167 +++++++++++++++++++++++++++++++++++++ index.js | 22 +++++ package.json | 17 ++++ wrangler.toml | 41 +++++++++ 5 files changed, 258 insertions(+) create mode 100644 .github/workflows/deep.yml create mode 100644 .gitignore create mode 100644 index.js create mode 100644 package.json create mode 100644 wrangler.toml diff --git a/.github/workflows/deep.yml b/.github/workflows/deep.yml new file mode 100644 index 0000000..2c3051d --- /dev/null +++ b/.github/workflows/deep.yml @@ -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 }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4138168 --- /dev/null +++ b/.gitignore @@ -0,0 +1,167 @@ +# Logs + +logs +_.log +npm-debug.log_ +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) + +report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json + +# Runtime data + +pids +_.pid +_.seed +\*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover + +lib-cov + +# Coverage directory used by tools like istanbul + +coverage +\*.lcov + +# nyc test coverage + +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) + +.grunt + +# Bower dependency directory (https://bower.io/) + +bower_components + +# node-waf configuration + +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) + +build/Release + +# Dependency directories + +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) + +web_modules/ + +# TypeScript cache + +\*.tsbuildinfo + +# Optional npm cache directory + +.npm + +# Optional eslint cache + +.eslintcache + +# Optional stylelint cache + +.stylelintcache + +# Microbundle cache + +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history + +.node_repl_history + +# Output of 'npm pack' + +\*.tgz + +# Yarn Integrity file + +.yarn-integrity + +# parcel-bundler cache (https://parceljs.org/) + +.cache +.parcel-cache + +# Next.js build output + +.next +out + +# Nuxt.js build / generate output + +.nuxt +dist + +# Gatsby files + +.cache/ + +# Comment in the public line in if your project uses Gatsby and not Next.js + +# https://nextjs.org/blog/next-9-1#public-directory-support + +# public + +# vuepress build output + +.vuepress/dist + +# vuepress v2.x temp and cache directory + +.temp +.cache + +# Docusaurus cache and generated files + +.docusaurus + +# Serverless directories + +.serverless/ + +# FuseBox cache + +.fusebox/ + +# DynamoDB Local files + +.dynamodb/ + +# TernJS port file + +.tern-port + +# Stores VSCode versions used for testing VSCode extensions + +.vscode-test + +# yarn v2 + +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.\* + +# wrangler project + +.dev.vars* +!.dev.vars.example +.env* +!.env.example +.wrangler/ diff --git a/index.js b/index.js new file mode 100644 index 0000000..3315f75 --- /dev/null +++ b/index.js @@ -0,0 +1,22 @@ +// A simple, secure proxy for the Cloudflare API +export default { + async fetch(request) { + const corsHeaders = { + 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS', + 'Access-Control-Allow-Headers': 'Authorization, Content-Type', + }; + if (request.method === 'OPTIONS') { + return new Response(null, { headers: corsHeaders }); + } + const url = new URL(request.url); + const apiUrl = `https://api.cloudflare.com${url.pathname}${url.search}`; + const newRequest = new Request(apiUrl, request); + const response = await fetch(newRequest); + const newResponse = new Response(response.body, response); + Object.entries(corsHeaders).forEach(([key, value]) => { + newResponse.headers.set(key, value); + }); + return newResponse; + }, +}; diff --git a/package.json b/package.json new file mode 100644 index 0000000..4d94171 --- /dev/null +++ b/package.json @@ -0,0 +1,17 @@ +{ + "name": "apip", + "version": "0.0.0", + "private": true, + "type": "module", + "scripts": { + "deploy": "wrangler deploy", + "dev": "wrangler dev", + "start": "wrangler dev" + }, + "dependencies": { + + }, + "devDependencies": { + "wrangler": "4.33.*" + } +} diff --git a/wrangler.toml b/wrangler.toml new file mode 100644 index 0000000..35d7bb1 --- /dev/null +++ b/wrangler.toml @@ -0,0 +1,41 @@ +# For more details on how to configure Wrangler, refer to: +# https://developers.cloudflare.com/workers/wrangler/configuration/ + +name = "apip" +main = "index.js" +compatibility_date = "2025-09-09" + +# Durable Objects +# [[migrations]] +# tag = "v1" +# new_sqlite_classes = ["MyDurableObject"] + +# [durable_objects] +# bindings = [ +# { name = "MY_DURABLE_OBJECT", class_name = "MyDurableObject" } +# ] + +[observability] +enabled = true + +# Smart Placement +# Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement +# [placement] +# mode = "smart" + +# Environment Variables +# https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables +# [vars] +# MY_VARIABLE = "production_value" + +# Static Assets +# https://developers.cloudflare.com/workers/static-assets/binding/ +# [assets] +# directory = "./public/" +# binding = "ASSETS" + +# Service Bindings (communicate between multiple Workers) +# https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings +# [[services]] +# binding = "MY_SERVICE" +# service = "my-service"