New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

http-context-nodejs

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-context-nodejs - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

2

package.json
{
"name": "http-context-nodejs",
"version": "1.0.0",
"version": "1.0.1",
"description": "Get and set request-scoped context anywhere, and use it in any framework.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

# HTTP Context NodeJS
Get and set request-scoped context anywhere, and use it in any framework.
## Installation
It requires node v8.2.1 or higher for ES2015 and async_hooks support.
```bash
$ npm i http-context-nodejs
```
## Quick start
### TODO
### Express
### Nest
### Koa
### How to use it in [NestJS](https://nestjs.com/)
#### Set it in the MainJS
```js
...
import * as uuid from 'node-uuid';
import * as httpContext from 'http-context-nodejs'
...
app.use((req: Request, res: Response, next: NextFunction) => {
httpContext.scope();
httpContext.set('traceId', uuid.v1());
next();
});
...
```
#### Use it in anywhere
```js
import * as httpContext from 'http-context-nodejs'
...
const traceId = httpContext.get('traceId');
...
```
### How to use it in ExpressJS
#### Set it in the AppJS
```js
...
import * as uuid from 'node-uuid';
import * as httpContext from 'http-context-nodejs';
...
app.use((req, res, next) => {
httpContext.scope();
httpContext.set('traceId', uuid.v1());
next();
});
...
```
### Use it in anywhere
```js
import * as httpContext from 'http-context-nodejs'
...
const traceId = httpContext.get('traceId');
...
```
## How it works
### TODO
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc