Skip to content

v0.5.0

Pre-release
Pre-release

Choose a tag to compare

@johnspurlock-skymethod johnspurlock-skymethod released this 24 May 13:00
· 466 commits to master since this release

Summary

  • Initial support for R2! Overview doc
  • Mitigations for the breaking changes in the latest Deno version 1.22.0, which removed Deno.emit
    • denoflare relied on Deno.emit bundling in serve and push!
    • New version relies on deno bundle under the hood (see below for details)
  • Option to specify/override script environment bindings via the command line, no .denoflare config file needed for complicated workers
  • Declarative support for Custom Domains for Workers, bind a worker to your custom domain (even an apex domain) via denoflare push

Installation

New in this release (R2-related):

  • r2: TypeScript types for the R2Bucket runtime API
  • cli: denoflare r2 <subcommand>
    • vhost-style by default, option for explicit path or vhost
  • r2: associated functions in common/r2
    • r2.ts exports 21 lightweight r2 s3-compatible API operation functions, and common utils like v4 signing etc
    • self-contained, no deps on aws or aws4fetch, can be used within workers themselves
    • new namespace-aware parsing functions in common/xml_parser.ts
    • new dep on fast-xml-parser
    • can be remote imported from Deno projects
    • or bundled to a single javascript file for non-Deno environments
      • deno bundle https://raw.githubusercontent.com/skymethod/denoflare/v0.5.0/common/r2/r2.ts -> 99k unminified, 48k minified, 13k gzipped (includes fast-xml-parser)
    • put-object supports streaming uploads for large files
Supported operations
  listBuckets
  headBucket
  createBucket
  deleteBucket
  getBucketEncryption
  deleteBucketEncryption
  putBucketEncryption
  getBucketLocation

  listObjects
  listObjectsV2
  getObject
  headObject
  putObject
  deleteObject
  deleteObjects
  copyObject

  createMultipartUpload
  abortMultipartUpload
  completeMultipartUpload
  uploadPart
  uploadPartCopy
  • serve,push: new worker binding to an existing r2 bucket

    • can also be used locally in serve, will proxy local calls to the real bucket over the r2 s3-compatible api
    • works in both localIsolation modes (none, isolate)
  • r2-public-read: New example worker for making a bucket public

    • supports conditional requests, range requests, and objects stored with pre-existing content-encoding
    • optional input flag to enable directory listing as html, configurable page limit
    • optional input flag to enable routing similar to Cloudflare Pages, index.html served for directories, etc
    • optional allow/deny ip lists
    • can be deployed as is to a custom domain in a zone you own with a single push command
denoflare push https://raw.githubusercontent.com/skymethod/denoflare/v0.5.0/examples/r2-public-read-worker/worker.ts \
   --name my-bucket-public-read \
   --r2-bucket-binding bucket:my-bucket \
   --text-binding flags:listDirectories \
   --custom-domain my-bucket.my-domain.com \
   --account-id $CF_ACCOUNT_ID \
   --api-token $CF_API_TOKEN
  • r2-presigned-url: New example worker for making a bucket available via presigned GET requests
    • generate private credentials to use only with users to this presigned worker (e.g. $USER_ACCESS_KEY:$USER_SECRET_KEY below) so you don't have to use actual r2 credentials
    • generate them with a new cli command: denoflare r2 generate-credentials
    • generate presigned urls using s3 standard tools like presign
  AWS_ACCESS_KEY_ID=$USER_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY=$USER_SECRET_ACCESS_KEY \
  aws s3 presign s3://b/video.mp4 --endpoint-url https://my-bucket.my-domain.com
  • r2-presigned-url: (continued)
    • optional allow/deny ip lists
    • configurable maxSkewMinutes, default: 15
    • configurable maxExpiresMinutes, default: 7 days
    • supports conditional requests, range requests, and objects stored with pre-existing content-encoding
    • can be deployed as is to a custom domain in a zone you own with a single push command
 denoflare push https://raw.githubusercontent.com/skymethod/denoflare/v0.5.0/examples/r2-presigned-url-worker/worker.ts \
   --name my-bucket-public-read \
   --r2-bucket-binding bucket:my-bucket \
   --secret-binding credentials:$USER_ACCESS_KEY_ID:$USER_SECRET_ACCESS_KEY \
   --custom-domain my-bucket.my-domain.com \
   --account-id $CF_ACCOUNT_ID \
   --api-token $CF_API_TOKEN
  • analytics: New R2 analytics
    • Daily aggregate class a operations, class b operations, egress, storage, and associated costs
    • Per bucket cost, current storage, current object count, and egress
    • denoflare analytics r2

New in this release (non-R2-related):

  • tail: Handle new response status property coming back for each request message in all formatters including webtail.
  • cfapi: better cli docs for the supported subcommands
    • added list-zones, list/put/delete workers domains, list-memberships, list-accounts, list-scripts, get-user
  • push: New Script-level config property customDomains to define one or more custom domains on which to bind the worker when deploying, including apex domains!
  • uses the new Custom Domains for Workers
  • no additional route/dns setup needed
  • push: Use custom domains specified on the command line, if present.
  • push,serve: Option to override bindings from the command line.
  • push,serve: Ability to set --account-id and --api-token on the command line
    • .denoflare config no longer needed for workers with environment variable bindings!
  • cli: Unified cli command handling, all subcommands, arguments, and options available via --help
    • Abbreviated subcommand names are allowed when unambiguous. e.g. denoflare r2 lb instead of denoflare r2 list-buckets
  • deno: Support the latest Deno version 1.22.0, which removed Deno.emit, breaking us!
    • On 1.22+, bundling (for push and serve) is now done by spawning deno bundle under the hood
    • needs new --allow-run permission or --allow-run=~/.deno/bin/deno
    • Deno.emit is still used when running on Deno pre 1.22
    • The official replacement for Deno.emit is a new userland x/deno_emit module
      • Not a great replacement, they have no plans to ever type check in this module
      • Also quite buggy right now
      • Add --bundle backend=module if you want to try it out within denoflare instead of deno bundle
    • Renamed the emit utility function to bundle, supporting the three different backends: builtin (Deno.emit pre 1.22), process (deno bundle), and module (x/deno_emit)
  • do alarms: Updated types with getAlarm/setAlarm/deleteAlarm to try them out in production, no local emulation yet
  • docs: Tons of new documentation, including the ability to generate regenerate online docs pages for every cli command
  • site: New tweaks to support the new docs, like <Aside> and links inside code blocks