serverless README cleanups, wrangler.toml is gitignored

This commit is contained in:
Brandon Liu
2022-11-23 11:55:57 +08:00
parent 7c1315eeb8
commit 6b36663d10
4 changed files with 18 additions and 58 deletions

View File

@@ -1 +1,2 @@
dist
wrangler.toml

View File

@@ -1,30 +1,9 @@
# PMTiles on Cloudflare Workers
# Protomaps on Cloudflare
Use [rclone](https://rclone.org/downloads/) to upload your PMTiles archives to an R2 bucket. The Web UI is limited to 300 MB.
See installation and configuration instructions at [Protomaps Docs: Deploy on Cloudflare](https://protomaps.com/docs/cdn/cloudflare)
# Getting started
## Development
* First run `npm install` in the root `PMTiles/js` directory, then `npm install` in `PMTiles/serverless/cloudflare`
Option 1: with Wrangler, run `npm run start` to serve your Worker on http://localhost:8787. The cache will not be active in development.
* Edit `wrangler.toml` with a new name + your development and production R2 buckets.
* Test in development: `npm run start`
* Publish the worker: `npm run deploy`
# Settings
By default, your worker will serve tiles at path `NAME/0/0/0.EXT` using the archive at the root of your bucket `NAME.pmtiles`, where EXT is one of `mvt`, `png`, `jpg` or `webp` depending on the tileset.
This behavior can be customized with optional environment variables:
`PMTILES_PATH` - A string like `folder/{name}.pmtiles` specifying the path to archives in your bucket. Default `{name}.pmtiles`
`TILES_PATH` - a string like `prefix/{name}/{z}/{x}/{y}.{ext}` specifying the tile path exposed by the worker. Default `{name}/{z}/{x}/{y}.{ext}`
`ALLOWED_ORIGINS` - a comma-separated list of allowed CORS origions. Default none. Examples: `https://example.com,https://localhost:3000`, `*`
# Using the Workers web editor
Generate the Workers script using `npm run build` and copy `dist/index.js` to the editor.
Option 2: Generate the Workers script using `npm run build` and copy `dist/index.js` to the editor.

View File

@@ -3,7 +3,10 @@ main = "src/index.ts"
compatibility_date = "2022-10-18"
minify = true
# Replace the bucket names with your own
r2_buckets = [
{ binding = "BUCKET", preview_bucket_name = "my-bucket-development", bucket_name = "my-bucket-production" }
]
]
[vars]
# ALLOWED_ORIGINS = "http://localhost:8000"
# CACHE_MAX_AGE = 86400