scharff 1.0.0 → 1.1.0
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/README.md +25 -3
- package/index.js +3 -1
- package/package.json +14 -2
package/README.md
CHANGED
|
@@ -7,11 +7,33 @@ The project is using the fetch-intercept NPM package.
|
|
|
7
7
|
2) fork the git repository `https://github.com/Minka1902/scharff.git`, and place it next to your project.
|
|
8
8
|
|
|
9
9
|
## Usage
|
|
10
|
-
1) in your entry point, import unregister from the package: `const { unregister } = require('
|
|
11
|
-
2) to stop the logger just run the unregister function: `unregister()`
|
|
10
|
+
1) in your entry point, import unregister from the package: `const { unregister } = require('scharff');`
|
|
11
|
+
2) to stop the logger just run the unregister function: `unregister()`, or `npm uninstall scharff`.
|
|
12
12
|
|
|
13
13
|
## What to expect
|
|
14
|
-
The package will create a outgoingRequest.log file and start logging the requests to the file.
|
|
14
|
+
1) The package will create a outgoingRequest.log file and start logging the requests to the file.
|
|
15
|
+
2) In there you can see the fetch requests you sent.
|
|
16
|
+
3) The request will be in the format below:</br>
|
|
17
|
+
{</br>
|
|
18
|
+
"url":"http://www.example.com/update/ad423kbr1om82hu3d58a73g4",</br>
|
|
19
|
+
"originUrl":"/update/ad423kbr1om82hu3d58a73g4",</br>
|
|
20
|
+
"method":"GET",</br>
|
|
21
|
+
"headers": </br>
|
|
22
|
+
{</br>
|
|
23
|
+
"Content-Type":"application/json",</br>
|
|
24
|
+
"Access-Control-Allow-Origin":"*"</br>
|
|
25
|
+
},</br>
|
|
26
|
+
"body": </br>
|
|
27
|
+
{</br>
|
|
28
|
+
"isActive":true,</br>
|
|
29
|
+
"status":200,</br>
|
|
30
|
+
"date":"2023-08-21T11:25:47.023Z"</br>
|
|
31
|
+
}</br>
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
## Next release
|
|
35
|
+
1) Adding the date and time to the log.
|
|
36
|
+
2) Adding the IP address to the log.
|
|
15
37
|
|
|
16
38
|
## Future additions
|
|
17
39
|
1) We will add a request error logger.
|
package/index.js
CHANGED
|
@@ -5,8 +5,10 @@ const { removeBaseUrl } = require('./constants/functions');
|
|
|
5
5
|
module.exports.unregister = fetchIntercept.register({
|
|
6
6
|
request: function (url, config) {
|
|
7
7
|
let tempUrl = url;
|
|
8
|
-
tempUrl = removeBaseUrl(tempUrl);
|
|
9
8
|
let tempReq = { url };
|
|
9
|
+
let date = new Date().toLocaleString();
|
|
10
|
+
tempReq.date = date;
|
|
11
|
+
tempUrl = removeBaseUrl(tempUrl);
|
|
10
12
|
if (tempUrl !== url) {
|
|
11
13
|
tempReq.originUrl = tempUrl;
|
|
12
14
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scharff",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Logger for outgoing requests",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
8
|
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"logger",
|
|
11
|
+
"outgoing",
|
|
12
|
+
"request",
|
|
13
|
+
"response",
|
|
14
|
+
"error",
|
|
15
|
+
"fetch",
|
|
16
|
+
"fetch-inspector",
|
|
17
|
+
"inspector",
|
|
18
|
+
"scharff",
|
|
19
|
+
"npm"
|
|
20
|
+
],
|
|
9
21
|
"repository": {
|
|
10
22
|
"type": "git",
|
|
11
23
|
"url": "https://github.com/Minka1902/scharff.git"
|
|
@@ -15,4 +27,4 @@
|
|
|
15
27
|
"dependencies": {
|
|
16
28
|
"fetch-intercept": "^2.4.0"
|
|
17
29
|
}
|
|
18
|
-
}
|
|
30
|
+
}
|