@graffy/server 0.15.9 → 0.15.11-alpha.1

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.
Files changed (3) hide show
  1. package/index.cjs +4 -4
  2. package/index.mjs +4 -4
  3. package/package.json +2 -3
package/index.cjs CHANGED
@@ -24,7 +24,6 @@ var url = require("url");
24
24
  var common = require("@graffy/common");
25
25
  var debug = require("debug");
26
26
  var WebSocket = require("ws");
27
- var testing = require("@graffy/testing");
28
27
  function _interopDefaultLegacy(e) {
29
28
  return e && typeof e === "object" && "default" in e ? e : { "default": e };
30
29
  }
@@ -38,7 +37,7 @@ function server$1(store) {
38
37
  return async (req, res) => {
39
38
  const parsed = url__default["default"].parse(req.url, true);
40
39
  const query = parsed.query.q && common.decodeUrl(parsed.query.q);
41
- const options = parsed.query.opts && common.deserialize(decodeURIComponent(parsed.query.opts));
40
+ const options = parsed.query.opts && !Array.isArray(parsed.query.opts) && common.deserialize(decodeURIComponent(parsed.query.opts));
42
41
  if (req.method === "GET") {
43
42
  try {
44
43
  if (req.headers["accept"] === "text/event-stream") {
@@ -89,6 +88,7 @@ data: ${e.message}
89
88
  const payload = common.deserialize(Buffer.concat(chunks).toString());
90
89
  const value = await store.call(op, payload, options);
91
90
  res.writeHead(200);
91
+ console.log("Responding with", value);
92
92
  res.end(common.serialize(value));
93
93
  } catch (e) {
94
94
  res.writeHead(400);
@@ -122,7 +122,7 @@ function server(store) {
122
122
  const result = await store.call(op, payload, options);
123
123
  ws.send(common.serialize([id, null, result]));
124
124
  } catch (e) {
125
- log(op + "error:" + e.message + " " + testing.format(payload));
125
+ log(op + "error:" + e.message + " " + payload);
126
126
  ws.send(common.serialize([id, e.message]));
127
127
  }
128
128
  break;
@@ -136,7 +136,7 @@ function server(store) {
136
136
  ws.send(common.serialize([id, null, value]));
137
137
  }
138
138
  } catch (e) {
139
- log(op + "error:" + e.message + " " + testing.format(payload));
139
+ log(op + "error:" + e.message + " " + payload);
140
140
  ws.send(common.serialize([id, e.message]));
141
141
  }
142
142
  break;
package/index.mjs CHANGED
@@ -21,7 +21,6 @@ import url from "url";
21
21
  import { decodeUrl, deserialize, serialize } from "@graffy/common";
22
22
  import debug from "debug";
23
23
  import WebSocket from "ws";
24
- import { format } from "@graffy/testing";
25
24
  const log$1 = debug("graffy:server:http");
26
25
  function server$1(store) {
27
26
  if (!store)
@@ -29,7 +28,7 @@ function server$1(store) {
29
28
  return async (req, res) => {
30
29
  const parsed = url.parse(req.url, true);
31
30
  const query = parsed.query.q && decodeUrl(parsed.query.q);
32
- const options = parsed.query.opts && deserialize(decodeURIComponent(parsed.query.opts));
31
+ const options = parsed.query.opts && !Array.isArray(parsed.query.opts) && deserialize(decodeURIComponent(parsed.query.opts));
33
32
  if (req.method === "GET") {
34
33
  try {
35
34
  if (req.headers["accept"] === "text/event-stream") {
@@ -80,6 +79,7 @@ data: ${e.message}
80
79
  const payload = deserialize(Buffer.concat(chunks).toString());
81
80
  const value = await store.call(op, payload, options);
82
81
  res.writeHead(200);
82
+ console.log("Responding with", value);
83
83
  res.end(serialize(value));
84
84
  } catch (e) {
85
85
  res.writeHead(400);
@@ -113,7 +113,7 @@ function server(store) {
113
113
  const result = await store.call(op, payload, options);
114
114
  ws.send(serialize([id, null, result]));
115
115
  } catch (e) {
116
- log(op + "error:" + e.message + " " + format(payload));
116
+ log(op + "error:" + e.message + " " + payload);
117
117
  ws.send(serialize([id, e.message]));
118
118
  }
119
119
  break;
@@ -127,7 +127,7 @@ function server(store) {
127
127
  ws.send(serialize([id, null, value]));
128
128
  }
129
129
  } catch (e) {
130
- log(op + "error:" + e.message + " " + format(payload));
130
+ log(op + "error:" + e.message + " " + payload);
131
131
  ws.send(serialize([id, e.message]));
132
132
  }
133
133
  break;
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.15.9",
5
+ "version": "0.15.11-alpha.1",
6
6
  "main": "./index.cjs",
7
7
  "exports": {
8
8
  "import": "./index.mjs",
@@ -17,8 +17,7 @@
17
17
  "license": "Apache-2.0",
18
18
  "dependencies": {
19
19
  "ws": "^7.0.0",
20
- "@graffy/common": "0.15.9",
21
- "@graffy/testing": "0.15.9",
20
+ "@graffy/common": "0.15.11-alpha.1",
22
21
  "debug": "^4.3.2"
23
22
  }
24
23
  }