# cls-middleware

> Connect & Restify middleware to bind routes to continuation-local storage

Latest version **1.1.0** (published 2014-01-14) · BSD-2-Clause license · 0 weekly downloads

## Install

```sh
npm install cls-middleware
pnpm add cls-middleware
yarn add cls-middleware
bun add cls-middleware
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2014-01-14 |
| First published | 2013-10-26 |
| Weekly downloads | 0 |
| License | BSD-2-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 21 |
| Author | Forrest L Norvell |
| Maintainers | othiym23 |
| Keywords | continuation-local-storage, express |

## Links

- npm: https://www.npmjs.com/package/cls-middleware
- Repository: https://github.com/othiym23/cls-middleware
- Issues: https://github.com/othiym23/cls-middleware/issues
- npm.io page: https://npm.io/package/cls-middleware

## Dependencies (1)

- [continuation-local-storage](https://npm.io/package/continuation-local-storage.md) ~3

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2014-01-14
- 1.0.1 — 2013-12-10
- 1.0.0 — 2013-10-26

## README

## Connect / Restify middleware for CLS

Dirt-simple middleware for Connect and Restify handlers into a
continuation-local storage context.

Example `app.js`:

```js
var cls     = require('continuation-local-storage');
var express = require('express');
var clsify  = require('cls-middleware');
var route   = require('./route.js');

var ns = cls.createNamespace('namespace');

var app = express();
app.use(clsify(ns));

ns.set('whatever', 'a value');

app.get('/users', route);
```

with `./route.js`:

```js
var cls = require('continuation-local-storage');

module.exports = function (req, res, next) {
  // pulling from the namespace, and set up per request
  res.send({value : cls.getNameSpace('namespace').get('whatever')});

  next();
};
```

---
_Source: https://npm.io/package/cls-middleware · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
