@jsenv/server 12.5.4 → 12.5.5
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/server",
|
|
3
|
-
"version": "12.5.
|
|
3
|
+
"version": "12.5.5",
|
|
4
4
|
"description": "Write your Node.js server using pure functions",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
"node": ">=16.13.0"
|
|
17
17
|
},
|
|
18
18
|
"publishConfig": {
|
|
19
|
-
"access": "public"
|
|
20
|
-
"registry": "https://registry.npmjs.org"
|
|
19
|
+
"access": "public"
|
|
21
20
|
},
|
|
22
21
|
"type": "module",
|
|
23
22
|
"exports": {
|
|
@@ -68,4 +67,4 @@
|
|
|
68
67
|
"playwright": "1.18.1",
|
|
69
68
|
"prettier": "2.5.1"
|
|
70
69
|
}
|
|
71
|
-
}
|
|
70
|
+
}
|
|
@@ -11,6 +11,7 @@ export const composeTwoResponses = (firstResponse, secondResponse) => {
|
|
|
11
11
|
const RESPONSE_KEYS_COMPOSITION = {
|
|
12
12
|
status: (prevStatus, status) => status,
|
|
13
13
|
statusText: (prevStatusText, statusText) => statusText,
|
|
14
|
+
statusMessage: (prevStatusMessage, statusMessage) => statusMessage,
|
|
14
15
|
headers: composeTwoHeaders,
|
|
15
16
|
body: (prevBody, body) => body,
|
|
16
17
|
bodyEncoding: (prevEncoding, encoding) => encoding,
|
package/src/startServer.js
CHANGED
|
@@ -291,26 +291,27 @@ export const startServer = async ({
|
|
|
291
291
|
// keep buffering until root request write logs for everyone
|
|
292
292
|
return
|
|
293
293
|
}
|
|
294
|
-
|
|
295
294
|
const writeLog = ({ type, value }, depth) => {
|
|
296
295
|
if (depth > 0) {
|
|
297
296
|
value = value.replace(/^(?!\s*$)/gm, " ".repeat(depth))
|
|
298
297
|
}
|
|
299
298
|
logger[type](value)
|
|
300
299
|
}
|
|
301
|
-
|
|
302
300
|
const visitRequestNodeToLog = (requestNode, depth) => {
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
301
|
+
const firstLog = requestNode.logs.shift()
|
|
302
|
+
const lastLog = requestNode.logs.pop()
|
|
303
|
+
const middleLogs = requestNode.logs
|
|
304
|
+
writeLog(firstLog, depth)
|
|
305
|
+
middleLogs.forEach((log) => {
|
|
306
|
+
writeLog(log, depth + 1)
|
|
306
307
|
})
|
|
307
308
|
requestNode.children.forEach((child) => {
|
|
308
309
|
visitRequestNodeToLog(child, depth + 1)
|
|
309
310
|
})
|
|
310
|
-
|
|
311
|
-
|
|
311
|
+
if (lastLog) {
|
|
312
|
+
writeLog(lastLog, depth + 1)
|
|
313
|
+
}
|
|
312
314
|
}
|
|
313
|
-
|
|
314
315
|
visitRequestNodeToLog(rootRequestNode, 0)
|
|
315
316
|
}
|
|
316
317
|
nodeRequest.on("error", (error) => {
|
|
@@ -589,6 +590,7 @@ export const startServer = async ({
|
|
|
589
590
|
const {
|
|
590
591
|
status = 501,
|
|
591
592
|
statusText,
|
|
593
|
+
statusMessage,
|
|
592
594
|
headers = {},
|
|
593
595
|
body,
|
|
594
596
|
...rest
|
|
@@ -596,6 +598,7 @@ export const startServer = async ({
|
|
|
596
598
|
const responseProperties = {
|
|
597
599
|
status,
|
|
598
600
|
statusText,
|
|
601
|
+
statusMessage,
|
|
599
602
|
headers,
|
|
600
603
|
body,
|
|
601
604
|
...rest,
|
|
@@ -669,10 +672,12 @@ export const startServer = async ({
|
|
|
669
672
|
})
|
|
670
673
|
onRequestHandled(requestNode)
|
|
671
674
|
},
|
|
672
|
-
onHeadersSent: ({ status, statusText }) => {
|
|
675
|
+
onHeadersSent: ({ status, statusText, statusMessage }) => {
|
|
673
676
|
addRequestLog(requestNode, {
|
|
674
677
|
type: "info",
|
|
675
|
-
value: `${colorizeResponseStatus(status)} ${
|
|
678
|
+
value: `${colorizeResponseStatus(status)} ${
|
|
679
|
+
statusMessage || statusText
|
|
680
|
+
}`,
|
|
676
681
|
})
|
|
677
682
|
},
|
|
678
683
|
onEnd: () => {
|