From 66f509566e5f2d9ca1f81600ac3a82b81ca380c8 Mon Sep 17 00:00:00 2001 From: Gabriel Massadas Date: Sun, 1 Dec 2024 20:33:08 +0000 Subject: [PATCH] Add cloudflare create configurations --- c3.ts | 7 ++ template/.gitignore | 173 +++++++++++++++++++++++++++++++++++++++++ template/README.md | 40 ++++++++++ template/package.json | 16 ++++ template/src/index.ts | 9 +++ template/tsconfig.json | 25 ++++++ template/wrangler.toml | 9 +++ 7 files changed, 279 insertions(+) create mode 100644 c3.ts create mode 100644 template/.gitignore create mode 100644 template/README.md create mode 100644 template/package.json create mode 100644 template/src/index.ts create mode 100644 template/tsconfig.json create mode 100644 template/wrangler.toml diff --git a/c3.ts b/c3.ts new file mode 100644 index 0000000..1b9d4f1 --- /dev/null +++ b/c3.ts @@ -0,0 +1,7 @@ +export default { + configVersion: 1, + id: "r2explorer", + displayName: "R2Explorer interface for your Cloudflare R2 Buckets!", + platform: "workers", + copyFiles: { path: './template' } +}; diff --git a/template/.gitignore b/template/.gitignore new file mode 100644 index 0000000..3067abc --- /dev/null +++ b/template/.gitignore @@ -0,0 +1,173 @@ +# 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 + +# dotenv environment variable files + +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# 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 +.wrangler/ +.idea/ diff --git a/template/README.md b/template/README.md new file mode 100644 index 0000000..bfb9344 --- /dev/null +++ b/template/README.md @@ -0,0 +1,40 @@ +# My Personal R2 Explorer + +This is my personal [R2 Explorer](https://github.com/G4brym/R2-Explorer) application self hosted on my Cloudflare account. + +You can read the full [documentation here](https://r2explorer.dev/). + +## Get started + +1. Sign up for [Cloudflare Workers](https://workers.dev). The free tier is more than enough for this, you will only pay + for the [R2 storage](https://developers.cloudflare.com/r2/pricing/). +2. Clone this project and install dependencies with `npm install` +3. Run `wrangler login` to login to your Cloudflare account in wrangler +4. Run `wrangler deploy` to publish to Cloudflare Workers + +### Optional Steps + +1. Read only mode is enabled by default, disable it in `src/index.ts`, [documentation here](https://r2explorer.dev/getting-started/configuration/#disabling-readonly-mode). +2. Learn how to secure your R2 Explorer in the official [documentation here](https://r2explorer.dev/getting-started/security/). + +## Updating the instance + +Install latest version + +```bash +npm install r2-explorer@latest --save +``` + +Deploy to Cloudflare Workers + +```bash +wrangler deploy +``` + +## Deploying + +Deploy to Cloudflare Workers + +```bash +wrangler deploy +``` diff --git a/template/package.json b/template/package.json new file mode 100644 index 0000000..ebafb21 --- /dev/null +++ b/template/package.json @@ -0,0 +1,16 @@ +{ + "name": "", + "version": "1.0.0", + "private": true, + "scripts": { + "deploy": "wrangler deploy", + "dev": "wrangler dev", + "start": "wrangler dev" + }, + "dependencies": { + "r2-explorer": "^1.0.0" + }, + "devDependencies": { + "wrangler": "^3.91.0" + } +} diff --git a/template/src/index.ts b/template/src/index.ts new file mode 100644 index 0000000..4c4872e --- /dev/null +++ b/template/src/index.ts @@ -0,0 +1,9 @@ +import { R2Explorer } from 'r2-explorer'; + +export default R2Explorer({ + readonly: true, + // basicAuth: { + // username: 'username', + // password: 'password' + // } +}); diff --git a/template/tsconfig.json b/template/tsconfig.json new file mode 100644 index 0000000..df71750 --- /dev/null +++ b/template/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + /* Base Options: */ + "esModuleInterop": true, + "skipLibCheck": true, + "target": "es2022", + "verbatimModuleSyntax": false, + "allowJs": true, + "resolveJsonModule": true, + "moduleDetection": "force", + /* Strictness */ + "noImplicitAny": false, + "noImplicitThis": true, + "strictNullChecks": false, + "strict": true, + "noUncheckedIndexedAccess": true, + /* If NOT transpiling with TypeScript: */ + "moduleResolution": "Bundler", + "module": "es2022", + "noEmit": true, + /* If your code runs in the DOM: */ + "lib": ["es2022"] + }, + "include": ["src"] +} diff --git a/template/wrangler.toml b/template/wrangler.toml new file mode 100644 index 0000000..3eca9ff --- /dev/null +++ b/template/wrangler.toml @@ -0,0 +1,9 @@ +name = "" +main = "src/index.ts" +compatibility_date = "" + +# Bind R2 Buckets to your application. +# Docs: https://r2explorer.dev/getting-started/add-r2-buckets/ +# [[r2_buckets]] +# binding = "MY_BUCKET" +# bucket_name = "my-bucket"