@graffy/server 0.15.25-alpha.1 → 0.15.25-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.
- package/index.cjs +17 -37
- package/index.mjs +10 -24
- package/package.json +2 -2
package/index.cjs
CHANGED
|
@@ -1,40 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (__hasOwnProp.call(b, prop))
|
|
12
|
-
__defNormalProp(a, prop, b[prop]);
|
|
13
|
-
if (__getOwnPropSymbols)
|
|
14
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
-
if (__propIsEnum.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
}
|
|
18
|
-
return a;
|
|
19
|
-
};
|
|
20
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports[Symbol.toStringTag] = "Module";
|
|
23
|
-
var url = require("url");
|
|
24
|
-
var common = require("@graffy/common");
|
|
25
|
-
var debug = require("debug");
|
|
26
|
-
var ws = require("ws");
|
|
27
|
-
function _interopDefaultLegacy(e) {
|
|
28
|
-
return e && typeof e === "object" && "default" in e ? e : { "default": e };
|
|
29
|
-
}
|
|
30
|
-
var url__default = /* @__PURE__ */ _interopDefaultLegacy(url);
|
|
31
|
-
var debug__default = /* @__PURE__ */ _interopDefaultLegacy(debug);
|
|
32
|
-
const log$1 = debug__default["default"]("graffy:server:http");
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const url = require("url");
|
|
4
|
+
const common = require("@graffy/common");
|
|
5
|
+
const debug = require("debug");
|
|
6
|
+
const ws = require("ws");
|
|
7
|
+
const _interopDefaultLegacy = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
|
|
8
|
+
const url__default = /* @__PURE__ */ _interopDefaultLegacy(url);
|
|
9
|
+
const debug__default = /* @__PURE__ */ _interopDefaultLegacy(debug);
|
|
10
|
+
const log$1 = debug__default.default("graffy:server:http");
|
|
33
11
|
function server$1(store, { auth } = {}) {
|
|
34
12
|
if (!store)
|
|
35
13
|
throw new Error("server.store_undef");
|
|
36
14
|
return async (req, res) => {
|
|
37
|
-
const parsed = url__default
|
|
15
|
+
const parsed = url__default.default.parse(req.url, true);
|
|
38
16
|
const options = parsed.query.opts && !Array.isArray(parsed.query.opts) && common.deserialize(decodeURIComponent(parsed.query.opts)) || void 0;
|
|
39
17
|
if (req.method === "GET") {
|
|
40
18
|
const query = parsed.query.q && common.decodeUrl(parsed.query.q);
|
|
@@ -49,9 +27,10 @@ function server$1(store, { auth } = {}) {
|
|
|
49
27
|
res.write(": \n\n");
|
|
50
28
|
}, 29e3);
|
|
51
29
|
try {
|
|
52
|
-
const stream = store.call("watch", query,
|
|
30
|
+
const stream = store.call("watch", query, {
|
|
31
|
+
...options,
|
|
53
32
|
raw: true
|
|
54
|
-
})
|
|
33
|
+
});
|
|
55
34
|
for await (const value of stream) {
|
|
56
35
|
if (req.aborted || res.finished)
|
|
57
36
|
break;
|
|
@@ -106,7 +85,7 @@ data: ${e.message}
|
|
|
106
85
|
}
|
|
107
86
|
};
|
|
108
87
|
}
|
|
109
|
-
const log = debug__default
|
|
88
|
+
const log = debug__default.default("graffy:server:ws");
|
|
110
89
|
const PING_INTERVAL = 3e4;
|
|
111
90
|
function server(store) {
|
|
112
91
|
if (!store)
|
|
@@ -134,9 +113,10 @@ function server(store) {
|
|
|
134
113
|
break;
|
|
135
114
|
case "watch":
|
|
136
115
|
try {
|
|
137
|
-
const stream = store.call("watch", payload,
|
|
116
|
+
const stream = store.call("watch", payload, {
|
|
117
|
+
...options,
|
|
138
118
|
raw: true
|
|
139
|
-
})
|
|
119
|
+
});
|
|
140
120
|
ws2.graffyStreams[id] = stream;
|
|
141
121
|
for await (const value of stream) {
|
|
142
122
|
ws2.send(common.serialize([id, null, value]));
|
package/index.mjs
CHANGED
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
1
|
import url from "url";
|
|
21
2
|
import { deserialize, decodeUrl, serialize } from "@graffy/common";
|
|
22
3
|
import debug from "debug";
|
|
@@ -41,9 +22,10 @@ function server$1(store, { auth } = {}) {
|
|
|
41
22
|
res.write(": \n\n");
|
|
42
23
|
}, 29e3);
|
|
43
24
|
try {
|
|
44
|
-
const stream = store.call("watch", query,
|
|
25
|
+
const stream = store.call("watch", query, {
|
|
26
|
+
...options,
|
|
45
27
|
raw: true
|
|
46
|
-
})
|
|
28
|
+
});
|
|
47
29
|
for await (const value of stream) {
|
|
48
30
|
if (req.aborted || res.finished)
|
|
49
31
|
break;
|
|
@@ -126,9 +108,10 @@ function server(store) {
|
|
|
126
108
|
break;
|
|
127
109
|
case "watch":
|
|
128
110
|
try {
|
|
129
|
-
const stream = store.call("watch", payload,
|
|
111
|
+
const stream = store.call("watch", payload, {
|
|
112
|
+
...options,
|
|
130
113
|
raw: true
|
|
131
|
-
})
|
|
114
|
+
});
|
|
132
115
|
ws.graffyStreams[id] = stream;
|
|
133
116
|
for await (const value of stream) {
|
|
134
117
|
ws.send(serialize([id, null, value]));
|
|
@@ -170,4 +153,7 @@ function server(store) {
|
|
|
170
153
|
});
|
|
171
154
|
};
|
|
172
155
|
}
|
|
173
|
-
export {
|
|
156
|
+
export {
|
|
157
|
+
server$1 as httpServer,
|
|
158
|
+
server as wsServer
|
|
159
|
+
};
|
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.25-alpha.
|
|
5
|
+
"version": "0.15.25-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.15.25-alpha.
|
|
19
|
+
"@graffy/common": "0.15.25-alpha.3",
|
|
20
20
|
"debug": "^4.3.3",
|
|
21
21
|
"ws": "^8.4.2"
|
|
22
22
|
}
|