Skip to content

Commit

Permalink
Add cloudflare create configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
G4brym committed Dec 1, 2024
1 parent 4c55905 commit 66f5095
Show file tree
Hide file tree
Showing 7 changed files with 279 additions and 0 deletions.
7 changes: 7 additions & 0 deletions c3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
configVersion: 1,
id: "r2explorer",
displayName: "R2Explorer interface for your Cloudflare R2 Buckets!",
platform: "workers",
copyFiles: { path: './template' }
};
173 changes: 173 additions & 0 deletions template/.gitignore
Original file line number Diff line number Diff line change
@@ -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/
40 changes: 40 additions & 0 deletions template/README.md
Original file line number Diff line number Diff line change
@@ -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
```
16 changes: 16 additions & 0 deletions template/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "<TBD>",
"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"
}
}
9 changes: 9 additions & 0 deletions template/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { R2Explorer } from 'r2-explorer';

export default R2Explorer({
readonly: true,
// basicAuth: {
// username: 'username',
// password: 'password'
// }
});
25 changes: 25 additions & 0 deletions template/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"]
}
9 changes: 9 additions & 0 deletions template/wrangler.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name = "<TBD>"
main = "src/index.ts"
compatibility_date = "<TBD>"

# Bind R2 Buckets to your application.
# Docs: https://r2explorer.dev/getting-started/add-r2-buckets/
# [[r2_buckets]]
# binding = "MY_BUCKET"
# bucket_name = "my-bucket"

0 comments on commit 66f5095

Please sign in to comment.