{"library":"request-context","title":"request-context","description":"Connect/Express middleware that wraps each request in a Node.js domain, providing a namespace to store and retrieve data across async callbacks within the same request lifecycle. Version 2.0.0 is the latest stable release. The package uses the deprecated Node.js 'domain' module, so it is not recommended for new projects. Alternatives include AsyncLocalStorage (Node.js 12.17+) or continuation-local-storage. It supports a simple key-value API with dot notation for nested property access.","language":"javascript","status":"maintenance","last_verified":"Sat Apr 25","install":{"commands":["npm install request-context"],"cli":null},"imports":["const contextService = require('request-context');","const { middleware } = require('request-context');","contextService.set('namespace:key', value);","const val = contextService.get('namespace:key');"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const express = require('express');\nconst contextService = require('request-context');\n\nconst app = express();\napp.use(contextService.middleware('request'));\n\napp.use((req, res, next) => {\n  contextService.set('request:user', { name: 'Alice' });\n  next();\n});\n\napp.get('/', (req, res) => {\n  const user = contextService.get('request:user.name');\n  res.send(`Hello ${user}`);\n});\n\napp.use((err, req, res, next) => {\n  res.status(500).send('Error');\n});\n\napp.listen(3000);","lang":"javascript","description":"Sets up Express with request-context middleware, sets a user object, and retrieves nested property via dot notation in route handler.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}