Summarize an Express-style HTTP request object. Tries to make result JSON-friendly.
This module exports an object that holds these functions:
Returns a function summarizeRequest(req)
,
which takes the request object and returns a summary that
- is an array suitable for passing as arguments to
console.log()
, - tries to be very concise.
opt
is an optional options object that supports these optional keys:
-
rawQuery
(boolean, default: true): Whether to report the original query string as part of the URL. Set tofalse
to remove everything after the initial question mark. -
parsedQuery
(boolean, default: false): Whether to report the data parsed from the query string, if any.- ⚠ Passing this to
console.log
can easily result in multi-line output.
- ⚠ Passing this to
Returns a function summarizeRequest(req)
,
which takes the request object and returns a summary that
- is a native (plain old) JS object,
- focusses on interesting parts,
- is rather detailed nonetheless,
- and usually is suitable for being JSON-encoded.
opt
is an optional options object that supports these optional keys:
-
(All names of default Key Name Lists ): See comments in that file for how to adjust them.
-
lowLineBoring
(boolean, default: true): Whether all keys whose name starts with U+005F low line (_
) are treated as being in thedefaultBoringKeys
Key Name List. -
unexpectedKeysKey
(string ornull
, default:'unexpected'
): Where to put the list of unexpected request keys.null
= omit from report.
:TODO:
- Needs more/better tests and docs.
ISC