@graffy/server 0.16.0-alpha.1 → 0.16.0-alpha.3

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 -2
package/index.cjs CHANGED
@@ -13,7 +13,7 @@ function server$1(store, { auth } = {}) {
13
13
  throw new Error("server.store_undef");
14
14
  return async (req, res) => {
15
15
  const parsed = url__default.default.parse(req.url, true);
16
- const options = parsed.query.opts && !Array.isArray(parsed.query.opts) && common.deserialize(decodeURIComponent(parsed.query.opts)) || void 0;
16
+ const options = parsed.query.opts && !Array.isArray(parsed.query.opts) && JSON.parse(decodeURIComponent(parsed.query.opts)) || void 0;
17
17
  if (req.method === "GET") {
18
18
  const query = parsed.query.q && common.deserialize(decodeURIComponent(parsed.query.q));
19
19
  try {
@@ -105,10 +105,10 @@ function server(store) {
105
105
  case "write":
106
106
  try {
107
107
  const result = await store.call(op, payload, options);
108
- ws2.send(common.serialize([id, null, result]));
108
+ ws2.send([id, null, common.serialize(result)].join(":"));
109
109
  } catch (e) {
110
110
  log(op + "error:" + e.message + " " + payload);
111
- ws2.send(common.serialize([id, e.message]));
111
+ ws2.send([id, e.message].join(":"));
112
112
  }
113
113
  break;
114
114
  case "watch":
@@ -119,7 +119,7 @@ function server(store) {
119
119
  });
120
120
  ws2.graffyStreams[id] = stream;
121
121
  for await (const value of stream) {
122
- ws2.send(common.serialize([id, null, value]));
122
+ ws2.send([id, null, common.serialize(value)].join(":"));
123
123
  }
124
124
  } catch (e) {
125
125
  log(op + "error:" + e.message + " " + payload);
package/index.mjs CHANGED
@@ -8,7 +8,7 @@ function server$1(store, { auth } = {}) {
8
8
  throw new Error("server.store_undef");
9
9
  return async (req, res) => {
10
10
  const parsed = url.parse(req.url, true);
11
- const options = parsed.query.opts && !Array.isArray(parsed.query.opts) && deserialize(decodeURIComponent(parsed.query.opts)) || void 0;
11
+ const options = parsed.query.opts && !Array.isArray(parsed.query.opts) && JSON.parse(decodeURIComponent(parsed.query.opts)) || void 0;
12
12
  if (req.method === "GET") {
13
13
  const query = parsed.query.q && deserialize(decodeURIComponent(parsed.query.q));
14
14
  try {
@@ -100,10 +100,10 @@ function server(store) {
100
100
  case "write":
101
101
  try {
102
102
  const result = await store.call(op, payload, options);
103
- ws.send(serialize([id, null, result]));
103
+ ws.send([id, null, serialize(result)].join(":"));
104
104
  } catch (e) {
105
105
  log(op + "error:" + e.message + " " + payload);
106
- ws.send(serialize([id, e.message]));
106
+ ws.send([id, e.message].join(":"));
107
107
  }
108
108
  break;
109
109
  case "watch":
@@ -114,7 +114,7 @@ function server(store) {
114
114
  });
115
115
  ws.graffyStreams[id] = stream;
116
116
  for await (const value of stream) {
117
- ws.send(serialize([id, null, value]));
117
+ ws.send([id, null, serialize(value)].join(":"));
118
118
  }
119
119
  } catch (e) {
120
120
  log(op + "error:" + e.message + " " + payload);
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.0-alpha.1",
5
+ "version": "0.16.0-alpha.3",
6
6
  "main": "./index.cjs",
7
7
  "exports": {
8
8
  "import": "./index.mjs",
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "license": "Apache-2.0",
18
18
  "dependencies": {
19
- "@graffy/common": "0.16.0-alpha.1",
19
+ "@graffy/common": "0.16.0-alpha.3",
20
20
  "debug": "^4.3.3",
21
21
  "ws": "^8.4.2"
22
22
  }