From 6e63df1f97b890a38f23b64464b230aba63b431b Mon Sep 17 00:00:00 2001 From: Theo Sanderson Date: Thu, 28 Jul 2022 16:27:01 +0000 Subject: [PATCH] Add nextstrain endpoint to server --- taxonium_backend/README.md | 5 ++++- taxonium_backend/server.js | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/taxonium_backend/README.md b/taxonium_backend/README.md index 80dde9c8..8f6492c3 100644 --- a/taxonium_backend/README.md +++ b/taxonium_backend/README.md @@ -1,9 +1,12 @@ # Backend -`nvm use 17.5` +`nvm use 18` `yarn install` +`node server.js --data_url https://cov2tree.nyc3.cdn.digitaloceanspaces.com/tfci-taxonium2.jsonl` + + `node --experimental-fetch server.js --database_dir ./database/ --port 8080 --ssl --config_json config.json` Non-SSL public: diff --git a/taxonium_backend/server.js b/taxonium_backend/server.js index d9b82dff..0b6d8ffd 100644 --- a/taxonium_backend/server.js +++ b/taxonium_backend/server.js @@ -11,6 +11,7 @@ var axios = require("axios"); var pako = require("pako"); var importing; var filtering; +var exporting; const { program } = require("commander"); @@ -73,6 +74,14 @@ import("taxonium_data_handling/filtering.js").then((imported) => { console.log("imported filtering"); }); + + +import("taxonium_data_handling/exporting.js").then((imported) => { + exporting = imported.default; + console.log("imported exporting"); +}); + + waitForTheImports = async () => { if (importing === undefined || filtering === undefined) { await new Promise((resolve) => { @@ -385,6 +394,14 @@ app.get("/tip_atts", async (req, res) => { ); }); + +app.get("/nextstrain_json", async (req, res) => { + const root_id = parseInt(req.query.root_id); + const json = await exporting.getNextstrainSubtreeJson(root_id, processedData.nodes); + res.send(json); + +}); + const loadData = async () => { await waitForTheImports(); let supplied_object;