diff --git a/.env.template b/.env.template index 92039b1..53cce9a 100644 --- a/.env.template +++ b/.env.template @@ -1 +1,2 @@ OWLREPO_URL=https://owlrepo-nonprod.wl.r.appspot.com +PROJECT_ID=owlrepo-nonprod diff --git a/app.nonprod.yaml b/app.nonprod.yaml index b56bcb9..408ee48 100644 --- a/app.nonprod.yaml +++ b/app.nonprod.yaml @@ -2,4 +2,5 @@ runtime: nodejs14 entrypoint: node __sapper__/build env_variables: + PROJECT_ID: owlrepo-nonprod OWLREPO_URL: https://api-v1-3s5yebp5cq-uc.a.run.app diff --git a/app.prod.yaml b/app.prod.yaml index 7e8709d..044cd08 100644 --- a/app.prod.yaml +++ b/app.prod.yaml @@ -2,4 +2,5 @@ runtime: nodejs14 entrypoint: node __sapper__/build env_variables: + PROJECT_ID: owlrepo OWLREPO_URL: https://api-v1-6jpxgj6jpa-uc.a.run.app diff --git a/src/routes/api/v2/data/[task_id]/[prefix].js b/src/routes/api/v2/data/[task_id]/[prefix].js new file mode 100644 index 0000000..ad01482 --- /dev/null +++ b/src/routes/api/v2/data/[task_id]/[prefix].js @@ -0,0 +1,8 @@ +const BUCKET = process.env.PROJECT_ID; + +export async function get(req, res, next) { + const { task_id, prefix } = req.params; + res.redirect( + `https://storage.googleapis.com/${BUCKET}/v1/uploads/${task_id}/${prefix}` + ); +} diff --git a/src/routes/api/v2/query/[prefix].js b/src/routes/api/v2/query/[prefix].js new file mode 100644 index 0000000..ee6dce2 --- /dev/null +++ b/src/routes/api/v2/query/[prefix].js @@ -0,0 +1,8 @@ +const BUCKET = process.env.PROJECT_ID; + +export async function get(req, res, next) { + const { prefix } = req.params; + res.redirect( + `https://storage.googleapis.com/${BUCKET}/v1/queries/${prefix}.json` + ); +} diff --git a/src/routes/index.svelte b/src/routes/index.svelte index 95d6595..ab6b897 100644 --- a/src/routes/index.svelte +++ b/src/routes/index.svelte @@ -1,3 +1,16 @@ + + @@ -44,12 +47,10 @@ to see more plots this this.

-{#if random_listing} - -{/if} +

Contributions

@@ -70,9 +71,7 @@

Upload Activity

-{#if heatmap} - -{/if} +
diff --git a/src/server.js b/src/server.js index 844cdaf..8b2e008 100644 --- a/src/server.js +++ b/src/server.js @@ -17,6 +17,21 @@ server.use( }) ); +// simple redirect middleware +// https://github.com/lukeed/polka/issues/78#issuecomment-600496930 +server.use(function (req, res, next) { + res.redirect = (location) => { + let str = `Redirecting to ${location}`; + res.writeHead(302, { + Location: location, + "Content-Type": "text/plain", + "Content-Length": str.length, + }); + res.end(str); + }; + next(); +}); + server .use( compression({ threshold: 0 }),