aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/locations
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2022-10-26 10:41:11 -0700
committerAdam Soltys <[email protected]>2022-10-26 10:41:13 -0700
commitd6199b5b2ce430d757b252cce57cbe6fbfa15059 (patch)
treede87c7ea5b7a33d3c4b1b3c48aac53b27d96367e /src/routes/locations
parent3d901bc14fe78293bf9fbf9fa804cb637b9a32e1 (diff)
downloadcoinos-ui-d6199b5b2ce430d757b252cce57cbe6fbfa15059.tar.gz
coinos-ui-d6199b5b2ce430d757b252cce57cbe6fbfa15059.zip
cache and filter osm locations fetch
Diffstat (limited to 'src/routes/locations')
-rw-r--r--src/routes/locations/+server.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/routes/locations/+server.js b/src/routes/locations/+server.js
new file mode 100644
index 00000000..48eb9fc6
--- /dev/null
+++ b/src/routes/locations/+server.js
@@ -0,0 +1,18 @@
+import { json } from '@sveltejs/kit';
+
+export async function GET({ fetch, setHeaders }) {
+ let r = await fetch('https://api.btcmap.org/v2/elements?updated_since=2022-09-19');
+
+ let locations = await r.json();
+ locations = locations.filter(
+ (l) => l['osm_json'].tags && l['osm_json'].tags['payment:coinos'] === 'yes'
+ );
+
+ let headers = {
+ 'cache-control': 'public, max-age=600'
+ };
+
+ setHeaders(headers);
+
+ return json({ locations });
+}