Gathering detailed insights and metrics for morgan-body-ext
Gathering detailed insights and metrics for morgan-body-ext
Gathering detailed insights and metrics for morgan-body-ext
Gathering detailed insights and metrics for morgan-body-ext
npm install morgan-body-ext
Typescript
Module System
Node Version
NPM Version
55.3
Supply Chain
90
Quality
75.6
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
19,533
Last Day
5
Last Week
20
Last Month
97
Last Year
1,838
3 Stars
31 Commits
2 Watching
2 Branches
1 Contributors
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
Cumulative downloads
Total Downloads
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
3
5
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:
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});
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
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
3 existing vulnerabilities detected
Details
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
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
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