statebus 7.0.15 → 7.0.17
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/client-library.js +5 -2
- package/package.json +1 -1
- package/server-library.js +7 -5
- package/statebus.js +6 -6
package/client-library.js
CHANGED
|
@@ -107,12 +107,15 @@
|
|
|
107
107
|
patches: the_put.patches
|
|
108
108
|
}
|
|
109
109
|
).then(function (res) {
|
|
110
|
-
if (res.status
|
|
110
|
+
if (res.status === 200) {
|
|
111
|
+
console.log('PUT succeeded!')
|
|
112
|
+
puts.delete(id)
|
|
113
|
+
}
|
|
114
|
+
else
|
|
111
115
|
console.error(
|
|
112
116
|
'Server gave error on PUT:', e,
|
|
113
117
|
'for', {body: the_put.body, patches: the_put.patches}
|
|
114
118
|
)
|
|
115
|
-
puts.delete(id)
|
|
116
119
|
}).catch(function (e) {
|
|
117
120
|
console.error(e, 'Error on PUT, waiting...', the_put.url)
|
|
118
121
|
the_put.status = 'waiting'
|
package/package.json
CHANGED
package/server-library.js
CHANGED
|
@@ -233,10 +233,12 @@ function import_server (bus, make_statebus, options)
|
|
|
233
233
|
patch.range + ' = ' + patch.content
|
|
234
234
|
)
|
|
235
235
|
var cbus = bus.bus_for_http_client(req, res)
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
236
|
+
var key = req.url.substr(1)
|
|
237
|
+
cbus.get_once(key, (obj) => {
|
|
238
|
+
cbus.set(key, {patch: statebus_patches})
|
|
239
|
+
res.sendStatus(200)
|
|
240
|
+
console.log('We just processed a patch!')
|
|
241
|
+
})
|
|
240
242
|
})
|
|
241
243
|
} else {
|
|
242
244
|
// Otherwise, we assume the body is content-type: json
|
|
@@ -2547,7 +2549,7 @@ function free_the_cors (req, res, next) {
|
|
|
2547
2549
|
var free_the_cors = {
|
|
2548
2550
|
"Access-Control-Allow-Origin": "*",
|
|
2549
2551
|
"Access-Control-Allow-Methods": "OPTIONS, HEAD, GET, PUT, DELETE, UNSUBSCRIBE",
|
|
2550
|
-
"Access-Control-Allow-Headers": "subscribe, peer, version, parents, merge-type, content-type, patches, cache-control, put-order"
|
|
2552
|
+
"Access-Control-Allow-Headers": "subscribe, peer, version, parents, merge-type, content-type, content-range, patches, cache-control, put-order"
|
|
2551
2553
|
}
|
|
2552
2554
|
Object.entries(free_the_cors).forEach(x => res.setHeader(x[0], x[1]))
|
|
2553
2555
|
if (req.method === 'OPTIONS') {
|
package/statebus.js
CHANGED
|
@@ -102,15 +102,15 @@
|
|
|
102
102
|
if (typeof obj === 'string' && t && t.patch) {
|
|
103
103
|
if (typeof t.patch == 'string') t.patch = [t.patch]
|
|
104
104
|
// Apply the patch locally
|
|
105
|
+
var key = obj,
|
|
106
|
+
obj = bus.cache[key]
|
|
107
|
+
|
|
105
108
|
console.log('set: applying the patch!', {
|
|
106
|
-
key:
|
|
107
|
-
|
|
109
|
+
key: key,
|
|
110
|
+
obj: obj,
|
|
108
111
|
patch: t.patch[0]
|
|
109
112
|
})
|
|
110
|
-
obj =
|
|
111
|
-
key: obj,
|
|
112
|
-
val: apply_patch((bus.cache[obj] && bus.cache[obj].val), t.patch[0])
|
|
113
|
-
}
|
|
113
|
+
obj.val = apply_patch(obj.val, t.patch[0])
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
if (!('key' in obj) || typeof obj.key !== 'string') {
|