From 2526bc15bf81e200cbc5fd1d91278a3efe1529fc Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Tue, 30 Apr 2024 23:14:57 +0200 Subject: [PATCH] Re-enable cache server --- Docs/ServerConfig/hetzner/hetzner.txt | 2 +- scripts/osm2pgsql/tilecountServer.ts | 1 + src/Utils.ts | 9 ++++++++- src/index.ts | 4 ++-- src/index_theme.ts.template | 2 +- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Docs/ServerConfig/hetzner/hetzner.txt b/Docs/ServerConfig/hetzner/hetzner.txt index d625e1f89..4009a6f92 100644 --- a/Docs/ServerConfig/hetzner/hetzner.txt +++ b/Docs/ServerConfig/hetzner/hetzner.txt @@ -9,4 +9,4 @@ For used hosts, see the Caddyfile As the ISP of Nerdlab is a bit picky, we use SSH-port-forwarding on the cache server: -`ssh -R ` +`ssh -R 5445:127.0.0.1:5445 hetzner` diff --git a/scripts/osm2pgsql/tilecountServer.ts b/scripts/osm2pgsql/tilecountServer.ts index 3c28aa803..8fa8fb162 100644 --- a/scripts/osm2pgsql/tilecountServer.ts +++ b/scripts/osm2pgsql/tilecountServer.ts @@ -38,6 +38,7 @@ class OsmPoiDatabase { this._client = new Client(connectionString) } + async getCount( layer: string, bbox: [[number, number], [number, number]] = undefined diff --git a/src/Utils.ts b/src/Utils.ts index eee1171e2..503c7ed7d 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -1042,7 +1042,14 @@ In the case that MapComplete is pointed to the testing grounds, the edit will be Utils._download_cache.set(url, { promise, timestamp: new Date().getTime() }) return await promise } - + public static async downloadJson( + url: string, + headers?: Record + ): Promise + public static async downloadJson( + url: string, + headers?: Record + ): Promise public static async downloadJson( url: string, headers?: Record diff --git a/src/index.ts b/src/index.ts index 3a9084c2e..2d5a1a03a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -30,8 +30,8 @@ async function getAvailableLayers(): Promise> { try { const host = new URL(Constants.VectorTileServer).host const status: { layers: string[] } = await Promise.any([ - // Utils.downloadJson("https://" + host + "/summary/status.json"), - timeout(0), + Utils.downloadJson<{layers}>("https://" + host + "/summary/status.json"), + timeout(2500), ]) return new Set(status.layers) } catch (e) { diff --git a/src/index_theme.ts.template b/src/index_theme.ts.template index 5079901b7..6092f8453 100644 --- a/src/index_theme.ts.template +++ b/src/index_theme.ts.template @@ -29,7 +29,7 @@ async function getAvailableLayers(): Promise> { try { const host = new URL(Constants.VectorTileServer).host const status = await Promise.any([ - // Utils.downloadJson("https://" + host + "/summary/status.json"), + Utils.downloadJson("https://" + host + "/summary/status.json"), timeout(0) ]) return new Set(status.layers)