@graffy/server 0.16.15 → 0.16.18
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/index.cjs +30 -10
- package/index.mjs +30 -10
- package/package.json +3 -3
package/index.cjs
CHANGED
|
@@ -51,8 +51,12 @@ data: ${e.message}
|
|
|
51
51
|
} catch (e) {
|
|
52
52
|
log$1(e.message);
|
|
53
53
|
log$1(e.stack);
|
|
54
|
-
|
|
55
|
-
res.
|
|
54
|
+
const body = `${e.message}`;
|
|
55
|
+
res.writeHead(400, {
|
|
56
|
+
"Content-Type": "text/plain",
|
|
57
|
+
"Content-Length": Buffer.byteLength(body)
|
|
58
|
+
});
|
|
59
|
+
res.end(body);
|
|
56
60
|
}
|
|
57
61
|
} else if (req.method === "POST") {
|
|
58
62
|
try {
|
|
@@ -69,22 +73,38 @@ data: ${e.message}
|
|
|
69
73
|
(op === "write" ? common.decodeGraph : common.decodeQuery)(payload),
|
|
70
74
|
options
|
|
71
75
|
)) {
|
|
72
|
-
|
|
73
|
-
res.
|
|
76
|
+
const body2 = "unauthorized";
|
|
77
|
+
res.writeHead(401, {
|
|
78
|
+
"Content-Type": "text/plain",
|
|
79
|
+
"Content-Length": Buffer.byteLength(body2)
|
|
80
|
+
});
|
|
81
|
+
res.end(body2);
|
|
74
82
|
return;
|
|
75
83
|
}
|
|
76
84
|
const value = await store.call(op, payload, options);
|
|
77
|
-
|
|
78
|
-
res.
|
|
85
|
+
const body = JSON.stringify(common.pack(value));
|
|
86
|
+
res.writeHead(200, {
|
|
87
|
+
"Content-Type": "application/json",
|
|
88
|
+
"Content-Length": Buffer.byteLength(body)
|
|
89
|
+
});
|
|
90
|
+
res.end(body);
|
|
79
91
|
} catch (e) {
|
|
80
92
|
log$1(e.message);
|
|
81
93
|
log$1(e.stack);
|
|
82
|
-
|
|
83
|
-
res.
|
|
94
|
+
const body = `${e.message}`;
|
|
95
|
+
res.writeHead(400, {
|
|
96
|
+
"Content-Type": "text/plain",
|
|
97
|
+
"Content-Length": Buffer.byteLength(body)
|
|
98
|
+
});
|
|
99
|
+
res.end(body);
|
|
84
100
|
}
|
|
85
101
|
} else {
|
|
86
|
-
|
|
87
|
-
res.
|
|
102
|
+
const body = "Not implemented";
|
|
103
|
+
res.writeHead(501, {
|
|
104
|
+
"Content-Type": "text/plain",
|
|
105
|
+
"Content-Length": Buffer.byteLength(body)
|
|
106
|
+
});
|
|
107
|
+
res.end(body);
|
|
88
108
|
}
|
|
89
109
|
};
|
|
90
110
|
}
|
package/index.mjs
CHANGED
|
@@ -49,8 +49,12 @@ data: ${e.message}
|
|
|
49
49
|
} catch (e) {
|
|
50
50
|
log$1(e.message);
|
|
51
51
|
log$1(e.stack);
|
|
52
|
-
|
|
53
|
-
res.
|
|
52
|
+
const body = `${e.message}`;
|
|
53
|
+
res.writeHead(400, {
|
|
54
|
+
"Content-Type": "text/plain",
|
|
55
|
+
"Content-Length": Buffer.byteLength(body)
|
|
56
|
+
});
|
|
57
|
+
res.end(body);
|
|
54
58
|
}
|
|
55
59
|
} else if (req.method === "POST") {
|
|
56
60
|
try {
|
|
@@ -67,22 +71,38 @@ data: ${e.message}
|
|
|
67
71
|
(op === "write" ? decodeGraph : decodeQuery)(payload),
|
|
68
72
|
options
|
|
69
73
|
)) {
|
|
70
|
-
|
|
71
|
-
res.
|
|
74
|
+
const body2 = "unauthorized";
|
|
75
|
+
res.writeHead(401, {
|
|
76
|
+
"Content-Type": "text/plain",
|
|
77
|
+
"Content-Length": Buffer.byteLength(body2)
|
|
78
|
+
});
|
|
79
|
+
res.end(body2);
|
|
72
80
|
return;
|
|
73
81
|
}
|
|
74
82
|
const value = await store.call(op, payload, options);
|
|
75
|
-
|
|
76
|
-
res.
|
|
83
|
+
const body = JSON.stringify(pack(value));
|
|
84
|
+
res.writeHead(200, {
|
|
85
|
+
"Content-Type": "application/json",
|
|
86
|
+
"Content-Length": Buffer.byteLength(body)
|
|
87
|
+
});
|
|
88
|
+
res.end(body);
|
|
77
89
|
} catch (e) {
|
|
78
90
|
log$1(e.message);
|
|
79
91
|
log$1(e.stack);
|
|
80
|
-
|
|
81
|
-
res.
|
|
92
|
+
const body = `${e.message}`;
|
|
93
|
+
res.writeHead(400, {
|
|
94
|
+
"Content-Type": "text/plain",
|
|
95
|
+
"Content-Length": Buffer.byteLength(body)
|
|
96
|
+
});
|
|
97
|
+
res.end(body);
|
|
82
98
|
}
|
|
83
99
|
} else {
|
|
84
|
-
|
|
85
|
-
res.
|
|
100
|
+
const body = "Not implemented";
|
|
101
|
+
res.writeHead(501, {
|
|
102
|
+
"Content-Type": "text/plain",
|
|
103
|
+
"Content-Length": Buffer.byteLength(body)
|
|
104
|
+
});
|
|
105
|
+
res.end(body);
|
|
86
106
|
}
|
|
87
107
|
};
|
|
88
108
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graffy/server",
|
|
3
3
|
"description": "Node.js library for building an API for a Graffy store.",
|
|
4
4
|
"author": "aravind (https://github.com/aravindet)",
|
|
5
|
-
"version": "0.16.
|
|
5
|
+
"version": "0.16.18",
|
|
6
6
|
"main": "./index.cjs",
|
|
7
7
|
"exports": {
|
|
8
8
|
"import": "./index.mjs",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"license": "Apache-2.0",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@graffy/common": "0.16.
|
|
19
|
+
"@graffy/common": "0.16.18",
|
|
20
20
|
"debug": "^4.3.3",
|
|
21
|
-
"ws": "^8.
|
|
21
|
+
"ws": "^8.17.0"
|
|
22
22
|
}
|
|
23
23
|
}
|