From 209541357356e2540e85d4a24d1fe0a65735eeb2 Mon Sep 17 00:00:00 2001 From: Brandon Liu Date: Wed, 19 Oct 2022 09:31:49 +0800 Subject: [PATCH] update cloudflare README [#80] --- serverless/cloudflare/.gitignore | 1 + serverless/cloudflare/README.md | 25 ++++++++----------------- 2 files changed, 9 insertions(+), 17 deletions(-) create mode 100644 serverless/cloudflare/.gitignore diff --git a/serverless/cloudflare/.gitignore b/serverless/cloudflare/.gitignore new file mode 100644 index 0000000..1521c8b --- /dev/null +++ b/serverless/cloudflare/.gitignore @@ -0,0 +1 @@ +dist diff --git a/serverless/cloudflare/README.md b/serverless/cloudflare/README.md index 1ad9111..e3b1fce 100644 --- a/serverless/cloudflare/README.md +++ b/serverless/cloudflare/README.md @@ -4,27 +4,18 @@ Use [rclone](https://rclone.org/downloads/) to upload your PMTiles archives to a # Getting started -Bundled single-file worker with all dependencies: +Edit `wrangler.toml` with a new name + your development and production R2 buckets. -[protomaps.github.io/PMTiles/worker.js](https://protomaps.github.io/PMTiles/worker.js) +Publish the worker: `npm deploy` -To generate `worker.js` from a checkout: - -```sh -git clone https://github.com/protomaps/PMTiles -cd serverless/cloudflare -npm run build -``` - -Copy `dist/worker.js` into the Cloudflare Workers editor. - -* In Settings > Variables, bind your bucket to the environment variable `BUCKET`. +# Settings By default, your worker will serve tiles at path `NAME/0/0/0.pbf` using the archive at the root of your bucket `NAME.pmtiles`. -This behavior can be customized with two optional environment variables: +This behavior can be customized with optional environment variables: -`PMTILES_PATH` - optional. -`TILE_PATH`- optional. -`CORS` - optional. +`PMTILES_PATH` - A string like `folder/{name}.pmtiles` specifying the path to archives in your bucket. Default `{name}.pmtiles` +# Using the Workers web editor + +Generate the Workers script using `npm run build` and copy `dist/index.js` to the editor. \ No newline at end of file