update cloudflare README [#80]

This commit is contained in:
Brandon Liu
2022-10-19 09:31:49 +08:00
parent 2033733643
commit 2095413573
2 changed files with 9 additions and 17 deletions

1
serverless/cloudflare/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
dist

View File

@@ -4,27 +4,18 @@ Use [rclone](https://rclone.org/downloads/) to upload your PMTiles archives to a
# Getting started # 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: # Settings
```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`.
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`. 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. `PMTILES_PATH` - A string like `folder/{name}.pmtiles` specifying the path to archives in your bucket. Default `{name}.pmtiles`
`TILE_PATH`- optional.
`CORS` - optional.
# Using the Workers web editor
Generate the Workers script using `npm run build` and copy `dist/index.js` to the editor.