@nxtedition/lib 13.0.2 → 13.0.4
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/deepstream.js +12 -8
- package/http.js +5 -4
- package/package.json +1 -1
package/deepstream.js
CHANGED
|
@@ -63,9 +63,8 @@ function parseKey(key) {
|
|
|
63
63
|
function observe(ds, name, ...args) {
|
|
64
64
|
let query = null
|
|
65
65
|
|
|
66
|
-
if (args.length && (args[0] == null || typeof args[0] === 'object')) {
|
|
66
|
+
if (args.length > 0 && (args[0] == null || typeof args[0] === 'object')) {
|
|
67
67
|
query = args.shift()
|
|
68
|
-
query = query ? JSON.parse(JSON.stringify(query)) : null
|
|
69
68
|
}
|
|
70
69
|
|
|
71
70
|
name = `${name}`
|
|
@@ -83,9 +82,8 @@ function observe(ds, name, ...args) {
|
|
|
83
82
|
function observe2(ds, name, ...args) {
|
|
84
83
|
let query = null
|
|
85
84
|
|
|
86
|
-
if (args.length && (args[0] == null || typeof args[0] === 'object')) {
|
|
85
|
+
if (args.length > 0 && (args[0] == null || typeof args[0] === 'object')) {
|
|
87
86
|
query = args.shift()
|
|
88
|
-
query = query ? JSON.parse(JSON.stringify(query)) : null
|
|
89
87
|
}
|
|
90
88
|
|
|
91
89
|
name = `${name}`
|
|
@@ -101,14 +99,20 @@ function observe2(ds, name, ...args) {
|
|
|
101
99
|
}
|
|
102
100
|
|
|
103
101
|
function get(ds, name, ...args) {
|
|
104
|
-
let
|
|
102
|
+
let query = null
|
|
105
103
|
|
|
106
|
-
if (args[0]
|
|
107
|
-
|
|
104
|
+
if (args.length > 0 && (args[0] == null || typeof args[0] === 'object')) {
|
|
105
|
+
query = args.shift()
|
|
108
106
|
}
|
|
109
107
|
|
|
108
|
+
name = `${name}`
|
|
109
|
+
|
|
110
110
|
return ds.record.get(
|
|
111
|
-
`${name}${
|
|
111
|
+
`${name}${
|
|
112
|
+
query && Object.keys(query).length > 0
|
|
113
|
+
? `${name.endsWith('?') ? '' : '?'}${qs.stringify(query, { skipNulls: true })}`
|
|
114
|
+
: ''
|
|
115
|
+
}`,
|
|
112
116
|
...args
|
|
113
117
|
)
|
|
114
118
|
}
|
package/http.js
CHANGED
|
@@ -7,6 +7,7 @@ const compose = require('koa-compose')
|
|
|
7
7
|
const http = require('http')
|
|
8
8
|
const fp = require('lodash/fp')
|
|
9
9
|
const tp = require('timers/promises')
|
|
10
|
+
const { AbortError } = require('./errors')
|
|
10
11
|
|
|
11
12
|
const ERR_HEADER_EXPR =
|
|
12
13
|
/^(content-length|content-type|te|host|upgrade|trailers|connection|keep-alive|http2-settings|transfer-encoding|proxy-connection|proxy-authenticate|proxy-authorization)$/i
|
|
@@ -55,10 +56,6 @@ module.exports.request = async function request(ctx, next) {
|
|
|
55
56
|
reqLogger.trace({ req }, 'request started')
|
|
56
57
|
}
|
|
57
58
|
|
|
58
|
-
if (!ctx.url) {
|
|
59
|
-
throw new createError.BadRequest()
|
|
60
|
-
}
|
|
61
|
-
|
|
62
59
|
const onClose = () => ac.abort()
|
|
63
60
|
const onTimeout = () => res.destroy(new createError.RequestTimeout())
|
|
64
61
|
const onError = (err) => ac.abort(err)
|
|
@@ -69,6 +66,10 @@ module.exports.request = async function request(ctx, next) {
|
|
|
69
66
|
|
|
70
67
|
await next()
|
|
71
68
|
|
|
69
|
+
if (!res.writableEnded && res.destroyed) {
|
|
70
|
+
throw new AbortError()
|
|
71
|
+
}
|
|
72
|
+
|
|
72
73
|
assert(res.writableEnded)
|
|
73
74
|
assert(res.statusCode)
|
|
74
75
|
|