# http-redis

> Configuration based Redis client for Express.

Latest version **0.0.0-rc.1.0** (published 2021-02-16) · SEE LICENSE IN <LICENSE> license · 0 weekly downloads

## Install

```sh
npm install http-redis
pnpm add http-redis
yarn add http-redis
bun add http-redis
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.0-rc.1.0 |
| Published | 2021-02-16 |
| First published | 2021-02-16 |
| Weekly downloads | 0 |
| License | SEE LICENSE IN <LICENSE> |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10.14.1 |
| Dependencies | 2 |
| Unpacked size | 37.2 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | ehbraheem@gmail.com |
| Maintainers | bolatan |

## Links

- npm: https://www.npmjs.com/package/http-redis
- Repository: https://github.com/Ehbraheem/express-redis.git#main
- Homepage: https://github.com/Ehbraheem/express-redis/tree/main#readme
- Issues: https://github.com/Ehbraheem/express-redis/issues
- npm.io page: https://npm.io/package/http-redis

## Dependencies (2)

- [joi](https://npm.io/package/joi.md) 17.4.0
- [ioredis](https://npm.io/package/ioredis.md) 4.22.0

## Recent versions

- 0.0.0-rc.1.0 (latest) — 2021-02-16

## README

# express-redis
Configuration based Redis client middleware for Express.

## Development setup

A quick guide to basic setup of the **express-redis** project on your local machine


## Redis installation

Redis can only be installed on Unix based systems (Mac OSX, and all linux variants) with addition of Windows 10's subsystem linux. Check the official documentation for details https://redis.io/download



## express-redis middleware options
There are 3 different connection `mode` supported by this middleware. `'regular' | 'sentinel' | 'cluster'`

### Regular mode options

```js
{
  mode: 'regular', // One of 'regular' | 'sentinel' | 'cluster' (Required)
  options: {
    port: 6379,
    host: "127.0.0.1", // Redis host
    options: {
      family: 4, // 4 (IPv4) or 6 (IPv6) (Optional)
      password: "auth", // If you have auth setup for your server (Optional)
      db: 0, // DB name to use (Optional)
    }
  }
}
```

### Sentinel mode options

```js
{
  mode: 'sentinel', // (Required)
  options: {
    sentinels: [ // List of sentinels to connect to (Required)
      { host: "localhost", port: 26379 },
      { host: "localhost", port: 26380 },
    ],
    name: "mymaster"
    role: "slave", // will return a random slave from the Sentinel group (Optional)
    family: 4, // 4 (IPv4) or 6 (IPv6) (Optional)
    sentinelPassword: "auth", // If you have auth setup for your server (Optional)
  }
}
```

### Cluster mode options

```js
{
  mode: 'cluster', // (Required)
  options: {
    nodes: [ // List of nodes to connect to (Required)
      { host: "localhost", port: 6380 },
      { host: "localhost", port: 6381 },
    ],
    options: {
      scaleReads: 'all' // Scale reads to the node with the specified role (Optional)
    }
  }
}
```

### PUB/SUB options
To avoid the event of blocking the redis instance connected to the server, all users of this plugin are required to set the below option for **pub/sub**.

#### Publisher option

```js
{
  mode: '', // MODE OF CHOICE. see below for examples
  publisherOption: true // false by default.
}
```

#### Subscriber options

```js
{
  subscriberOption: {
    subscribers: async () => console.log('Hello world'), // Function (Required)
    topics: [
      'LIST OF TOPICS'
    ]
  }
}
```

## Support
For more information on redis, here's a link to their [Official documentation](https://redis.io/documentation). For API documentation of the redis client driver used in this project, check their [documentation](https://github.com/luin/ioredis).

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