@sjcrh/proteinpaint-server 2.99.0 → 2.99.1-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 +2 -2
- package/routes/img.js +46 -0
- package/routes/termdb.config.js +1 -0
- package/routes/termdb.singlecellSamples.js +11 -0
- package/src/app.js +103 -50
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sjcrh/proteinpaint-server",
|
|
3
|
-
"version": "2.99.0",
|
|
3
|
+
"version": "2.99.1-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",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@sjcrh/augen": "2.87.0",
|
|
62
62
|
"@sjcrh/proteinpaint-rust": "2.99.0",
|
|
63
63
|
"@sjcrh/proteinpaint-shared": "2.99.0",
|
|
64
|
-
"@sjcrh/proteinpaint-types": "2.99.0",
|
|
64
|
+
"@sjcrh/proteinpaint-types": "2.99.1-0",
|
|
65
65
|
"better-sqlite3": "^9.4.1",
|
|
66
66
|
"body-parser": "^1.15.2",
|
|
67
67
|
"canvas": "~2.11.2",
|
package/routes/img.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { imgPayload } from "#types/checkers";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import * as utils from "../src/utils.js";
|
|
5
|
+
import imagesize from "image-size";
|
|
6
|
+
const api = {
|
|
7
|
+
endpoint: "img",
|
|
8
|
+
methods: {
|
|
9
|
+
get: {
|
|
10
|
+
...imgPayload,
|
|
11
|
+
init
|
|
12
|
+
},
|
|
13
|
+
post: {
|
|
14
|
+
...imgPayload,
|
|
15
|
+
init
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
function init() {
|
|
20
|
+
return async (req, res) => {
|
|
21
|
+
try {
|
|
22
|
+
sendImage(req, res);
|
|
23
|
+
} catch (e) {
|
|
24
|
+
res.send({ status: "error", error: e.message || e });
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
async function sendImage(req, res) {
|
|
29
|
+
const [e, file] = utils.fileurl(req, true);
|
|
30
|
+
try {
|
|
31
|
+
if (e)
|
|
32
|
+
throw "invalid image file";
|
|
33
|
+
const data = await fs.promises.readFile(file);
|
|
34
|
+
const ext = path.extname(file).substring(1);
|
|
35
|
+
const image = {
|
|
36
|
+
src: `data:image/${ext};base64,${Buffer.from(data).toString("base64")}`,
|
|
37
|
+
size: imagesize(file)
|
|
38
|
+
};
|
|
39
|
+
res.send({ ...image });
|
|
40
|
+
} catch (e2) {
|
|
41
|
+
res.send({ error: e2.message || e2 });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
api
|
|
46
|
+
};
|
package/routes/termdb.config.js
CHANGED
|
@@ -219,6 +219,7 @@ function addNonDictionaryQueries(c, ds, genome) {
|
|
|
219
219
|
sampleColumns: q.singleCell.samples.sampleColumns,
|
|
220
220
|
experimentColumns: q.singleCell.samples.experimentColumns
|
|
221
221
|
},
|
|
222
|
+
images: q.singleCell.images,
|
|
222
223
|
data: {
|
|
223
224
|
sameLegend: q.singleCell.data.sameLegend,
|
|
224
225
|
refName: q.singleCell.data.refName,
|
|
@@ -76,6 +76,17 @@ async function validate_query_singleCell(ds, genome) {
|
|
|
76
76
|
if (q.DEgenes) {
|
|
77
77
|
validate_query_singleCell_DEgenes(ds);
|
|
78
78
|
}
|
|
79
|
+
if (q.images) {
|
|
80
|
+
validateImages(q.images);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function validateImages(images) {
|
|
84
|
+
if (!images.folder)
|
|
85
|
+
throw "images.folder missing";
|
|
86
|
+
if (!images.label)
|
|
87
|
+
images.label = "Images";
|
|
88
|
+
if (!images.fileName)
|
|
89
|
+
throw "images.fileName missing";
|
|
79
90
|
}
|
|
80
91
|
async function validateSamplesNative(S, D, ds) {
|
|
81
92
|
const samples = /* @__PURE__ */ new Map();
|