@superhero/http-server 4.2.4 → 4.2.6
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/package.json +1 -1
- package/view.js +27 -3
package/package.json
CHANGED
package/view.js
CHANGED
|
@@ -24,7 +24,7 @@ export default class View
|
|
|
24
24
|
const headers = new Proxy({},
|
|
25
25
|
{
|
|
26
26
|
get : (target, prop) => target[prop] ?? downstream.getHeader(prop),
|
|
27
|
-
set : (_, prop, val) => downstream.setHeader(prop, val) ||
|
|
27
|
+
set : (_, prop, val) => downstream.setHeader(prop, val) || true,
|
|
28
28
|
has : (_, prop) => downstream.hasHeader(prop),
|
|
29
29
|
deleteProperty : (_, prop) => downstream.removeHeader(prop),
|
|
30
30
|
ownKeys : () => downstream.getHeaderNames()
|
|
@@ -50,7 +50,7 @@ export default class View
|
|
|
50
50
|
Object.defineProperties(this,
|
|
51
51
|
{
|
|
52
52
|
// The body property is an object that represents the response body.
|
|
53
|
-
body : { enumerable: true, get: () => body, set: (value) => body = deepmerge(body, value)
|
|
53
|
+
body : { enumerable: true, get: () => body, set: (value) => body = deepmerge(body, value) },
|
|
54
54
|
// The stream property is a transform stream in object mode that by default encodes objects
|
|
55
55
|
// as stringified JSON data records according to HTML5 standard Server-Sent Events (SSE).
|
|
56
56
|
stream : { enumerable: true, configurable: true, get: () => this.#lazyloadStream },
|
|
@@ -94,7 +94,8 @@ export default class View
|
|
|
94
94
|
if(descriptor?.writable
|
|
95
95
|
|| descriptor?.set)
|
|
96
96
|
{
|
|
97
|
-
|
|
97
|
+
this[property] = value
|
|
98
|
+
return true
|
|
98
99
|
}
|
|
99
100
|
else
|
|
100
101
|
{
|
|
@@ -284,4 +285,27 @@ export default class View
|
|
|
284
285
|
}
|
|
285
286
|
}
|
|
286
287
|
}
|
|
288
|
+
|
|
289
|
+
toJSON()
|
|
290
|
+
{
|
|
291
|
+
const
|
|
292
|
+
descriptors = Object.getOwnPropertyDescriptors(this),
|
|
293
|
+
output = {}
|
|
294
|
+
|
|
295
|
+
for(const property in descriptors)
|
|
296
|
+
{
|
|
297
|
+
if(descriptors[property].enumerable)
|
|
298
|
+
{
|
|
299
|
+
output[property] = this[property]
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
return Object(output)
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// It's useful for debugging and logging to provide a more readable output.
|
|
307
|
+
[Symbol.for('nodejs.util.inspect.custom')]()
|
|
308
|
+
{
|
|
309
|
+
return this.toJSON()
|
|
310
|
+
}
|
|
287
311
|
}
|