Installations
npm install shiny-express-formatter
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
8.4.0
NPM Version
5.5.1
Score
69.1
Supply Chain
87.8
Quality
75.4
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
Download Statistics
Total Downloads
16,005
Last Day
3
Last Week
8
Last Month
19
Last Year
142
GitHub Statistics
12 Commits
1 Forks
3 Watching
1 Branches
3 Contributors
Bundle Size
3.22 kB
Minified
1.47 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.0.0
Package Id
shiny-express-formatter@1.0.0
Size
2.63 kB
NPM Version
5.5.1
Node Version
8.4.0
Total Downloads
Cumulative downloads
Total Downloads
16,005
Last day
0%
3
Compared to previous day
Last week
-20%
8
Compared to previous week
Last month
90%
19
Compared to previous month
Last year
-42.3%
142
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Express Request/Response formatter
Formats requests and responses, and optionally bodies, for logging. When capturing response bodies, it only handles non-streaming requests. It is up to the app to determine what to do with the formatted objects
Example Request
{
"id": "7d575f6b-cac9-43cc-96f2-7695f909819d",
"headers": {
"host": "localhost:3080",
"connection": "keep-alive",
"accept": "application/json, text/plain, */*",
"user-agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36",
"referer": "http://localhost:3080/",
"accept-encoding": "gzip, deflate, sdch",
"accept-language": "en-US,en;q=0.8"
},
"method": "GET",
"path": "/api/widgets",
"body": {}
}
Example Response
{
"headers": {
"x-powered-by": "Express",
"content-length": "24",
"etag": "W/\"I4+1GQyv6zGcoXDQygDf+g==\""
},
"requestId": "7d575f6b-cac9-43cc-96f2-7695f909819d",
"time": 222,
"status": 200,
"size": 24,
"body": {
"widgets": [],
"links": []
}
}
Usage
Include the module
requestFormatter = require('shiny-express-formatter');
Add middleware for formatting requests/responses
app.use(requestFormatter.formatRequests(options));
Ensure any request body parsing middleware (e.g. body-parser) is set prior to using the formatting middleware
Options
-
onRequestCaptured
: function(requestLogObject). callback to run once request object has been formatted. Useful for capturing request id to set bunyan child loggers. default: do nothing -
onResponseCaptured
: function(requestLogObject, responseLogObject). callback to run once request and response objects have been formatted. default: do nothing -
captureRequestBody
: boolean|function(req). whether to include the request body in the callback. default: false. If set to a function, returned results will be the boolean that determines whether to capture the body (allows logging only json bodies, for example) -
captureResponseBody
: boolean|function(req, res). whether to include the response body in the callback. default: false. If set to a function, returned results will be the boolean that determines whether to capture the body (allows logging only json bodies, for example) -
logRequestHeaders
: boolean|function(req). whether to include the request body in the callback. default: true. If set to a function, returned results will be used as headers to log (allows filtering out sensitive headers) -
logResponseHeaders
: boolean|function(req, res). whether to include the response body in the callback. default: true. If set to a function, returned results will be used as headers to log (allows filtering out sensitive headers)
possible future work
- add options to create conditions for which types of request/response bodies are captured (e.g. json only)
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
Found 0/12 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
2.6
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More