@sjcrh/proteinpaint-server 2.108.1-0 → 2.108.6-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjcrh/proteinpaint-server",
3
- "version": "2.108.1-0",
3
+ "version": "2.108.6-0",
4
4
  "type": "module",
5
5
  "description": "a genomics visualization tool for exploring a cohort's genotype and phenotype data",
6
6
  "main": "src/app.js",
@@ -59,7 +59,7 @@
59
59
  },
60
60
  "dependencies": {
61
61
  "@sjcrh/augen": "2.87.0",
62
- "@sjcrh/proteinpaint-rust": "2.99.0",
62
+ "@sjcrh/proteinpaint-rust": "2.108.6-0",
63
63
  "@sjcrh/proteinpaint-shared": "2.108.0",
64
64
  "@sjcrh/proteinpaint-types": "2.108.0",
65
65
  "@types/express": "^5.0.0",
@@ -1,6 +1,6 @@
1
1
  import ky from "ky";
2
2
  import { joinUrl } from "#shared/joinUrl.js";
3
- import { run_rust_stream } from "@sjcrh/proteinpaint-rust";
3
+ import { stream_rust } from "@sjcrh/proteinpaint-rust";
4
4
  import { gdcMafPayload } from "#types/checkers";
5
5
  import { maxTotalSizeCompressed } from "./gdc.maf.ts";
6
6
  import { mayLog } from "#src/helpers.ts";
@@ -46,19 +46,38 @@ async function buildMaf(q, res, ds) {
46
46
  host: joinUrl(host.rest, "data")
47
47
  // must use the /data/ endpoint from current host
48
48
  };
49
- const rustStream = run_rust_stream("gdcmaf", JSON.stringify(arg));
50
- res.setHeader("Content-Type", "application/octet-stream");
51
- res.setHeader("Content-Disposition", "attachment; filename=cohort.maf.gz");
52
- rustStream.pipe(res);
53
- rustStream.on("end", () => {
49
+ const boundary = "GDC_MAF_MULTIPART_BOUNDARY";
50
+ res.setHeader("content-type", `multipart/mixed; boundary=${boundary}`);
51
+ res.write(`--${boundary}`);
52
+ res.write("\ncontent-disposition: attachment; filename=cohort.maf.gz");
53
+ res.write("\ncontent-type: application/octet-stream\n\n");
54
+ res.flush();
55
+ try {
56
+ const rustStream = stream_rust("gdcmaf", JSON.stringify(arg), emitJson);
57
+ if (rustStream) {
58
+ rustStream.pipe(res, { end: false }).on("error", (e) => {
59
+ if (!e)
60
+ return;
61
+ console.log(e);
62
+ });
63
+ } else {
64
+ emitJson({ error: "server error: undefined rustStream" });
65
+ }
66
+ } catch (e) {
67
+ console.log(e);
68
+ }
69
+ function emitJson(data, end = true) {
70
+ res.write(`
71
+ --${boundary}`);
72
+ res.write("\ncontent-type: application/json");
73
+ const json = typeof data === "string" ? data : JSON.stringify(data || { ok: true, status: "ok" });
74
+ res.write("\n\n" + json);
75
+ res.write(`
76
+ --${boundary}--`);
54
77
  mayLog("rust gdcmaf", Date.now() - t0);
55
- res.end();
56
- });
57
- rustStream.on("error", (err) => {
58
- console.error(err);
59
- res.statusCode = 500;
60
- res.end("Internal Server Error");
61
- });
78
+ if (end)
79
+ res.end();
80
+ }
62
81
  }
63
82
  async function getFileLstUnderSizeLimit(lst, host) {
64
83
  if (lst.length == 0)