Docket Upload Worker Setup

Docket Upload Worker Setup

This Cloudflare Worker enables PR-based docket uploads from the /docket/submit/ form.

Prerequisites

  1. A Cloudflare account with Workers enabled
  2. A GitHub Personal Access Token (PAT) with repo scope

Setup Steps

1. Create GitHub Personal Access Token

  1. Go to GitHub Settings > Developer settings > Personal access tokens > Tokens (classic)
  2. Click “Generate new token (classic)”
  3. Give it a descriptive name: “FaithFrontier Docket Worker”
  4. Select scopes:
    • repo (Full control of private repositories)
  5. Generate and save the token securely

2. Deploy Worker to Cloudflare

  1. Install Wrangler CLI:
    npm install -g wrangler
    
  2. Login to Cloudflare:
    wrangler login
    
  3. Create a new worker:
    cd worker
    wrangler init docket-upload
    
  4. Copy the worker.js content to your worker script

  5. Configure the worker:
    • Create wrangler.toml:
      name = "docket-upload"
      main = "worker.js"
      compatibility_date = "2024-01-01"
           
      [env.production]
      vars = { REPO_OWNER = "XTX33", REPO_NAME = "FaithFrontier" }
      
  6. Add the GitHub token as a secret:
    wrangler secret put GITHUB_PAT
    

    When prompted, paste your GitHub token

  7. Deploy:
    wrangler deploy
    
  8. Note the worker URL (e.g., https://docket-upload.your-subdomain.workers.dev)

3. Update the Submit Form

Edit /assets/js/docket-submit.js and replace the placeholder URL with your worker URL:

const workerUrl = 'https://docket-upload.your-subdomain.workers.dev/docket-upload';

4. Configure CORS (if needed)

If your worker URL is different from faithfrontier.org, update the CORS origin in worker.js:

'Access-Control-Allow-Origin': 'https://faithfrontier.org',

How It Works

  1. User fills out the form at /docket/submit/
  2. JavaScript sends PDF + metadata to Cloudflare Worker
  3. Worker creates a new git branch
  4. Worker uploads PDF to cases/<slug>/filings/
  5. Worker updates _data/docket/<slug>.yml with new entry
  6. Worker creates a Pull Request for review
  7. You review and merge the PR

Security

Alternative: Manual Upload

If you prefer not to use the worker, you can manually:

  1. Upload PDFs to the correct folder: cases/<slug>/filings/
  2. Edit _data/docket/<slug>.yml to add the entry
  3. Commit and push, or create a PR

Troubleshooting

Testing

Test the worker locally:

wrangler dev

Then update docket-submit.js temporarily to use http://localhost:8787 for testing.

Faith Frontier Music

Note: While we appreciate this music, Faith Frontier does not endorse any political views. If you hear anything that conflicts with our mission, please contact dTb33@PM.me. We will listen, consider removing the artist or song, or reply with pastoral advisement on why we left it up. Darkness to light.

Full songs require Spotify Premium. Free users hear 30-second previews. Click any song to open in Spotify for full playback. Artists receive credit for all plays.