@sjcrh/proteinpaint-server 2.70.4-2 → 2.71.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.
@@ -1,51 +0,0 @@
1
- import fs from "fs";
2
- import path from "path";
3
- import serverconfig from "#src/serverconfig.js";
4
- const api = {
5
- endpoint: "sampletiaimages",
6
- methods: {
7
- get: {
8
- init,
9
- request: {
10
- typeId: "GetSampleTiaImagesRequest"
11
- },
12
- response: {
13
- typeId: "GetSampleTiaImagesResponse"
14
- }
15
- },
16
- post: {
17
- alternativeFor: "get",
18
- init
19
- }
20
- }
21
- };
22
- function init({ genomes }) {
23
- return async (req, res) => {
24
- try {
25
- const g = genomes[req.query.genome];
26
- if (!g)
27
- throw "invalid genome name";
28
- const ds = g.datasets[req.query.dslabel];
29
- if (!ds)
30
- throw "invalid dataset name";
31
- const sampleId = req.query.sample_id;
32
- const sampleTiaImagesPath = path.join(
33
- `${serverconfig.tpmasterdir}/${ds.queries.TiaImages.imageBySampleFolder}`,
34
- sampleId
35
- );
36
- console.log("sampleId", sampleId);
37
- const sampleTiaImages = getTiaImages(sampleTiaImagesPath);
38
- res.send({ sampleTiaImages });
39
- } catch (e) {
40
- console.log(e);
41
- res.status(404).send("Sample images not found");
42
- }
43
- };
44
- }
45
- function getTiaImages(sampleImagesPath) {
46
- const files = fs.readdirSync(sampleImagesPath);
47
- return files.filter((file) => [".svs", ".mrxs"].includes(path.extname(file)));
48
- }
49
- export {
50
- api
51
- };
@@ -1,83 +0,0 @@
1
- import axios from "axios";
2
- import qs from "qs";
3
- import path from "path";
4
- import serverconfig from "#src/serverconfig.js";
5
- import fs from "fs";
6
- const routePath = "tiaimages";
7
- const api = {
8
- endpoint: `${routePath}`,
9
- methods: {
10
- get: {
11
- init,
12
- request: {
13
- typeId: "any"
14
- },
15
- response: {
16
- typeId: "any"
17
- }
18
- },
19
- post: {
20
- alternativeFor: "get",
21
- init
22
- }
23
- }
24
- };
25
- function init({ genomes }) {
26
- return async (req, res) => {
27
- try {
28
- const g = genomes[req.query.genome];
29
- if (!g)
30
- throw "invalid genome name";
31
- const ds = g.datasets[req.query.dslabel];
32
- if (!ds)
33
- throw "invalid dataset name";
34
- const sampleId = req.query.sampleId;
35
- if (!sampleId)
36
- throw "invalid sampleId";
37
- const sessionResponse = await axios.get(`${serverconfig.tileServerURL}/tileserver/session_id`, { withCredentials: true });
38
- const setCookieHeader = sessionResponse.headers["set-cookie"];
39
- const sessionId = setCookieHeader && setCookieHeader[0].split(";")[0].split("=")[1];
40
- console.log("sessionId", sessionId);
41
- const sampleTiaImagesPath = path.join(
42
- `${serverconfig.tpmasterdir}/${ds.queries.TiaImages.imageBySampleFolder}`,
43
- sampleId
44
- );
45
- const images = getTiaImages(sampleTiaImagesPath);
46
- const sampleTiaTileServer = path.join(
47
- `${serverconfig.tileServerMount}/${ds.queries.TiaImages.imageBySampleFolder}`,
48
- sampleId
49
- );
50
- const fname = `${sampleTiaTileServer}/${images[0]}`;
51
- const data = qs.stringify({ slide_path: fname });
52
- const putResponse = await axios.put(`${serverconfig.tileServerURL}/tileserver/slide`, data, {
53
- withCredentials: true,
54
- headers: {
55
- "Content-Type": "application/x-www-form-urlencoded",
56
- Cookie: `session_id=${sessionId}`
57
- // Include the session_id in the headers
58
- }
59
- });
60
- const getResponse = await axios.get(`${serverconfig.tileServerURL}/tileserver/slide`, {
61
- withCredentials: true,
62
- headers: {
63
- Cookie: `session_id=${sessionId}`
64
- // Include the session_id in the headers
65
- }
66
- });
67
- res.status(200).json({ sessionId, slide_dimensions: getResponse.data.slide_dimensions });
68
- } catch (e) {
69
- console.log(e);
70
- res.send({
71
- status: "error",
72
- error: e.error || e
73
- });
74
- }
75
- };
76
- }
77
- function getTiaImages(sampleImagesPath) {
78
- const files = fs.readdirSync(sampleImagesPath);
79
- return files.filter((file) => [".svs", ".mrxs"].includes(path.extname(file)));
80
- }
81
- export {
82
- api
83
- };
@@ -1,40 +0,0 @@
1
- import axios from "axios";
2
- import serverconfig from "#src/serverconfig.js";
3
- const routePath = "tileserver";
4
- const api = {
5
- endpoint: `${routePath}/layer/slide/:sampleId/zoomify/:TileGroup/:z-:x-:y@1x.jpg`,
6
- methods: {
7
- get: {
8
- init,
9
- request: {
10
- typeId: "any"
11
- },
12
- response: {
13
- typeId: "any"
14
- }
15
- },
16
- post: {
17
- alternativeFor: "get",
18
- init
19
- }
20
- }
21
- };
22
- function init() {
23
- return async (req, res) => {
24
- try {
25
- const { sampleId, TileGroup, z, x, y } = req.params;
26
- const url = `${serverconfig.tileServerURL}/tileserver/layer/slide/${sampleId}/zoomify/${TileGroup}/${z}-${x}-${y}@1x.jpg`;
27
- const response = await axios.get(url, { responseType: "arraybuffer" });
28
- res.status(response.status).send(response.data);
29
- } catch (error) {
30
- if (error.response) {
31
- res.status(error.response.status).send(error.response.data);
32
- } else {
33
- res.status(500).send("Internal Server Error");
34
- }
35
- }
36
- };
37
- }
38
- export {
39
- api
40
- };