correlation-id
Advanced tools
Comparing version
"use strict"; | ||
const { AsyncLocalStorage } = require("async_hooks"); | ||
const uuid = require("uuid"); | ||
const { randomUUID } = require("crypto"); | ||
@@ -26,4 +26,5 @@ const asyncLocalStorage = new AsyncLocalStorage(); | ||
work = id; | ||
id = uuid.v4(); | ||
id = randomUUID(); | ||
} | ||
if (!work) throw new Error("Missing work parameter"); | ||
@@ -30,0 +31,0 @@ |
{ | ||
"name": "correlation-id", | ||
"version": "4.0.0", | ||
"version": "5.0.0", | ||
"description": "Correlation id for node.js", | ||
"main": "index.js", | ||
"types": "index.d.ts", | ||
"files": [ | ||
"index.js", | ||
"test", | ||
"examples" | ||
"index.d.ts" | ||
], | ||
"engines": { | ||
"node": ">=12.17.0" | ||
"node": ">=14.17.0" | ||
}, | ||
"scripts": { | ||
"lint": "prettier --write . && eslint .", | ||
"lint": "prettier --check . && eslint .", | ||
"fmt": "prettier --write .", | ||
"test": "jest", | ||
"coverage": "jest --coverage", | ||
"coveralls": "coveralls < coverage/lcov.info" | ||
"test:coverage": "jest --coverage" | ||
}, | ||
@@ -36,12 +35,19 @@ "repository": { | ||
"homepage": "https://github.com/toboid/correlation-id#readme", | ||
"dependencies": { | ||
"uuid": "^8.3.1" | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"eslint": "^8.28.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"jest": "^29.3.1", | ||
"prettier": "^2.8.0" | ||
}, | ||
"devDependencies": { | ||
"coveralls": "^3.1.0", | ||
"eslint": "^7.13.0", | ||
"eslint-config-prettier": "^6.15.0", | ||
"jest": "^26.6.3", | ||
"prettier": "^2.1.2" | ||
"jest": { | ||
"coverageThreshold": { | ||
"global": { | ||
"branches": 100, | ||
"functions": 100, | ||
"lines": 100, | ||
"statements": 100 | ||
} | ||
} | ||
} | ||
} |
# Correlation id | ||
Correlation id maintains a consistent id across asynchronous calls in node.js applications. | ||
This is extremely useful for logging purposes. For example within an API, each incoming request can be assigned an id that will be available in all function calls made processing that request, so we can see which requests caused errors. | ||
Correlation id maintains a consistent id across asynchronous calls in node.js applications; this is especially useful for logging purposes. | ||
For example within an API, each incoming request can be assigned an id that will be available in all function calls made processing that request, so we can see which requests caused errors. | ||
100% test coverage, no prod dependencies. | ||
## Installation | ||
yarn: | ||
```shell | ||
yarn add correlation-id | ||
``` | ||
npm: | ||
```shell | ||
npm i correlation-id --save | ||
@@ -14,3 +25,3 @@ ``` | ||
From v4 onwards this library requires node >=12.17.0. For older node versions use v3.x. | ||
From v5 onwards this library requires node >=14. For older node versions use v3.x or v4.x. | ||
@@ -90,4 +101,8 @@ ## Simple example | ||
## Typesript | ||
Type defs are included. | ||
## License | ||
MIT |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
0
-100%4
-20%107
16.3%0
-100%6401
-6.57%5
-16.67%37
-32.73%- Removed
- Removed