Installations
npm install morgan-body-ext
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
12.22.11
NPM Version
6.14.16
Score
55.3
Supply Chain
90
Quality
75.6
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
jazzyinstyle
Download Statistics
Total Downloads
19,533
Last Day
5
Last Week
20
Last Month
97
Last Year
1,838
GitHub Statistics
3 Stars
31 Commits
2 Watching
2 Branches
1 Contributors
Package Meta Information
Latest Version
1.2.2
Package Id
morgan-body-ext@1.2.2
Unpacked Size
29.44 kB
Size
9.17 kB
File Count
4
NPM Version
6.14.16
Node Version
12.22.11
Publised On
13 Feb 2023
Total Downloads
Cumulative downloads
Total Downloads
19,533
Last day
0%
5
Compared to previous day
Last week
0%
20
Compared to previous week
Last month
10.2%
97
Compared to previous month
Last year
-48.1%
1,838
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
3
Dev Dependencies
5
morgan-body-ext
Important Note: The extra functionalities in this library have already been merge to it's parent morgan-body. Thanks!
This library is a customised version of the morgan-body.
The original morgan-body lacks the functionality to log additional request/response tokens like 'Request ID' which would be useful for log tracing purposes.
morgan-body-ext additionally logs these tokens as part of the original log format:
-
id: Request ID
-
request-headers: Request headers (JSON string)
-
response-headers: Response headers (JSON string)
You can also have the option to select only those request/response headers that you want to log by passing in these additional option-parameters:
- logAllReqHeader: true will log All request headers and take precedence over logReqHeaderList; false otherwise.
- logReqHeaderList: takes in a list of request headers to be displayed in the log.
- logAllResHeader: true will log All response headers and take precedence over logResHeaderList; false otherwise.
- logResHeaderList: takes in a list of response headers to be displayed in the log.
Example of Use
1const express = require('express');
2const bodyParser = require('body-parser');
3const morgan = require('morgan');
4const morganBody = require('morgan-body-ext');
5
6const app = express();
7
8/* Using 'express-request-id' to generate UUID for request
9and add it to X-Request-Id header.
10In case request contains X-Request-Id header, it uses its value instead.
11*/
12const requestId = require('express-request-id')();
13
14app.use(requestId);
15
16/* Create the 'id' token in morgan that returns the Request ID.
17Refer https://www.npmjs.com/package/morgan#tokens for more details.
18*/
19morgan.token('id', req => req.id);
20
21/* Parse body before morganBody as body will be logged */
22app.use(bodyParser.json());
23
24/* Hook morganBody to express app */
25morganBody(app, {
26 /* logAllReqHeader=true will log All request headers and take precedence over logReqHeaderList */
27 logAllReqHeader: false,
28 /* logReqHeaderList takes in a list of request headers to be displayed in the log */
29 logReqHeaderList: ['host', 'content-length', 'cache-control', 'origin', 'content-type', 'accept'],
30 /* logAllResHeader=true will log All response headers and take precedence over logResHeaderList */
31 logAllResHeader: false,
32 /* logResHeaderList takes in a list of response headers to be displayed in the log */
33 logResHeaderList: ['host', 'content-length', 'cache-control', 'origin', 'content-type', 'accept']
34});
Example of Generated Logs
2018-09-19T02:32:57.526Z info: [4bc80c25-7748-4fc6-9592-772723333390] Request: POST /sample?test=123 headers[host=localhost:3000;content-length=321;cache-control=no-cache;origin=chrome-extension://aicmkgpgakddgnaphhhpliifpcfhicfo;content-type=application/json;accept=*/*;]
2018-09-19T02:32:57.527Z info: [4bc80c25-7748-4fc6-9592-772723333390] Request Body:{"detail":"123","detail2":{"some-id":"123"}}
2018-09-19T02:32:57.528Z info: [4bc80c25-7748-4fc6-9592-772723333390] Response Body:{"some response body"}
2018-09-19T02:32:57.530Z info: [4bc80c25-7748-4fc6-9592-772723333390] Response: 200 headers[-] 2923.631 ms - 27
References
- Please refer to morgan-body for more usage example.
- UUID generation for Request: express-request-id
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
3 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/24 approved changesets -- 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
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 6 are checked with a SAST tool
Score
2.7
/10
Last Scanned on 2024-12-23
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