add getTileJson method to PMTiles class [#239, #247] (#453)

* add getTileJson method to PMTiles class [#239, #247]
* update docs related to FetchSource and headers [#397]
This commit is contained in:
Brandon Liu
2024-09-18 15:57:14 +08:00
committed by GitHub
parent 6ed85a28fb
commit 6f5479439b
7 changed files with 121 additions and 56 deletions

View File

@@ -14,7 +14,7 @@
"deploy": "wrangler deploy",
"test": "tsx ../shared/index.test.ts",
"tsc": "tsc --watch",
"build": "wrangler publish --outdir dist --dry-run",
"build": "wrangler deploy --outdir dist --dry-run",
"biome": "biome check --config-path=../../js/ src/index.ts --apply",
"biome-check": "biome check --config-path=../../js src/index.ts"
}

View File

@@ -7,7 +7,7 @@ import {
Source,
TileType,
} from "../../../js/index";
import { pmtiles_path, tileJSON, tile_path } from "../../shared/index";
import { pmtiles_path, tile_path } from "../../shared/index";
interface Env {
// biome-ignore lint: config name
@@ -159,14 +159,9 @@ export default {
if (!tile) {
cacheableHeaders.set("Content-Type", "application/json");
const t = tileJSON(
pHeader,
await p.getMetadata(),
env.PUBLIC_HOSTNAME || url.hostname,
name
const t = await p.getTileJson(
`https://${env.PUBLIC_HOSTNAME || url.hostname}/${name}`
);
return cacheableResponse(JSON.stringify(t), cacheableHeaders, 200);
}