scharff 1.0.4 → 1.0.5

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 CHANGED
@@ -6,8 +6,8 @@ Scharff is a lightweight and versatile Node.js package designed to enhance your
6
6
  2) fork the git repository `https://github.com/Minka1902/scharff.git`, and place it next to your project.
7
7
 
8
8
  ## Usage
9
- 1) in your entry point, import unregister from the package: `const { unregister } = require('scharff');`
10
- 2) to stop the logger just run the unregister function: `unregister()`, or `npm uninstall scharff`.
9
+ 1) in your entry point, import unregister from the package: `const listen = require('scharff');`
10
+ 2) to stop the logger just run the unregister function: `listen()`, or `npm uninstall scharff` in the terminal.
11
11
 
12
12
  ## What to expect
13
13
  1) The package will create a outgoingRequest.log file and start logging the requests to the file.
@@ -34,13 +34,13 @@ Scharff is a lightweight and versatile Node.js package designed to enhance your
34
34
  }
35
35
 
36
36
  ## New in this release
37
- 1) New date log.
38
-
37
+ 1) Fixed a bug in the installation
39
38
 
40
39
  ## Requirements
41
40
  1) nodejs version >= v18.0.0
42
41
 
43
42
  ## Future additions
44
- 1) We will add a request error logger.
45
- 2) We will add a response logger.
46
- 3) We will add a response error logger.
43
+ 1) Set the log file name
44
+ 2) Request error logger
45
+ 3) Response logger
46
+ 4) Response error logger
@@ -1,10 +1,17 @@
1
1
  module.exports.removeBaseUrl = (url) => {
2
- if (url) {
2
+ if (typeof url !== 'object') {
3
3
  const indexOfEnd = url.indexOf('/', 7);
4
4
  if (indexOfEnd === -1) {
5
5
  return url;
6
6
  } else {
7
7
  return url.slice(indexOfEnd, url.length);
8
8
  }
9
+ } else {
10
+ const indexOfEnd = url.url.indexOf('/', 7);
11
+ if (indexOfEnd === -1) {
12
+ return url.url;
13
+ } else {
14
+ return url.url.slice(indexOfEnd, url.url.length);
15
+ }
9
16
  }
10
17
  };
package/index.js CHANGED
@@ -3,7 +3,7 @@ const fetchIntercept = require('fetch-intercept');
3
3
  const fs = require('fs');
4
4
  const os = require('os');
5
5
 
6
- module.exports.unregister = fetchIntercept.register({
6
+ const listen = fetchIntercept.register({
7
7
  request: function (url, config) {
8
8
  const interfaces = os.networkInterfaces();
9
9
  let addresses = [];
@@ -91,3 +91,5 @@ module.exports.unregister = fetchIntercept.register({
91
91
  // return Promise.reject(error);
92
92
  // }
93
93
  });
94
+
95
+ module.exports = listen;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scharff",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Logger for outgoing requests",
5
5
  "main": "index.js",
6
6
  "scripts": {