forked from MapComplete/MapComplete
Re-enable cache server
This commit is contained in:
parent
7d313fedf8
commit
2526bc15bf
5 changed files with 13 additions and 5 deletions
|
@ -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:
|
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`
|
||||||
|
|
|
@ -38,6 +38,7 @@ class OsmPoiDatabase {
|
||||||
this._client = new Client(connectionString)
|
this._client = new Client(connectionString)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async getCount(
|
async getCount(
|
||||||
layer: string,
|
layer: string,
|
||||||
bbox: [[number, number], [number, number]] = undefined
|
bbox: [[number, number], [number, number]] = undefined
|
||||||
|
|
|
@ -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() })
|
Utils._download_cache.set(url, { promise, timestamp: new Date().getTime() })
|
||||||
return await promise
|
return await promise
|
||||||
}
|
}
|
||||||
|
public static async downloadJson(
|
||||||
|
url: string,
|
||||||
|
headers?: Record<string, string>
|
||||||
|
): Promise<object | []>
|
||||||
|
public static async downloadJson<T>(
|
||||||
|
url: string,
|
||||||
|
headers?: Record<string, string>
|
||||||
|
): Promise<T>
|
||||||
public static async downloadJson(
|
public static async downloadJson(
|
||||||
url: string,
|
url: string,
|
||||||
headers?: Record<string, string>
|
headers?: Record<string, string>
|
||||||
|
|
|
@ -30,8 +30,8 @@ async function getAvailableLayers(): Promise<Set<string>> {
|
||||||
try {
|
try {
|
||||||
const host = new URL(Constants.VectorTileServer).host
|
const host = new URL(Constants.VectorTileServer).host
|
||||||
const status: { layers: string[] } = await Promise.any([
|
const status: { layers: string[] } = await Promise.any([
|
||||||
// Utils.downloadJson("https://" + host + "/summary/status.json"),
|
Utils.downloadJson<{layers}>("https://" + host + "/summary/status.json"),
|
||||||
timeout(0),
|
timeout(2500),
|
||||||
])
|
])
|
||||||
return new Set<string>(status.layers)
|
return new Set<string>(status.layers)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -29,7 +29,7 @@ async function getAvailableLayers(): Promise<Set<string>> {
|
||||||
try {
|
try {
|
||||||
const host = new URL(Constants.VectorTileServer).host
|
const host = new URL(Constants.VectorTileServer).host
|
||||||
const status = await Promise.any([
|
const status = await Promise.any([
|
||||||
// Utils.downloadJson("https://" + host + "/summary/status.json"),
|
Utils.downloadJson("https://" + host + "/summary/status.json"),
|
||||||
timeout(0)
|
timeout(0)
|
||||||
])
|
])
|
||||||
return new Set<string>(status.layers)
|
return new Set<string>(status.layers)
|
||||||
|
|
Loading…
Reference in a new issue