You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

express-http-context

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-http-context - npm Package Compare versions

Comparing version

to
2.0.0-rc.4

7

index.d.ts

@@ -0,1 +1,3 @@

import { AsyncLocalStorage } from 'async_hooks';
/** Express.js middleware that is responsible for initializing the context for each request. */

@@ -17,1 +19,6 @@ export declare function middleware(

export declare function set(key: string, value: any): void;
/**
* Gets the instance of AsyncLocalStorage that is used to store the context for each request.
*/
export declare const asyncLocalStorage: AsyncLocalStorage<Map<string, unknown>>;

9

index.js

@@ -8,3 +8,7 @@ 'use strict';

function middleware(req, res, next) {
asyncLocalStorage.run(new Map(), next);
if (!asyncLocalStorage.getStore()) {
asyncLocalStorage.run(new Map(), () => next());
} else {
next();
}
}

@@ -36,3 +40,4 @@

get: get,
set: set
set: set,
asyncLocalStorage
};
{
"name": "express-http-context",
"version": "2.0.0-rc.3",
"version": "2.0.0-rc.4",
"description": "Get and set request-scoped context anywhere",

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