Skip to content

Commit

Permalink
Add nextstrain endpoint to server
Browse files Browse the repository at this point in the history
  • Loading branch information
theosanderson committed Jul 28, 2022
1 parent 328a9a8 commit 6e63df1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
5 changes: 4 additions & 1 deletion taxonium_backend/README.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
17 changes: 17 additions & 0 deletions taxonium_backend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var axios = require("axios");
var pako = require("pako");
var importing;
var filtering;
var exporting;

const { program } = require("commander");

Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 6e63df1

Please sign in to comment.