Socket
Book a DemoInstallSign in
Socket

botmaster-session-ware-redis-store

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

botmaster-session-ware-redis-store

Redis store adapter for the botmaster session ware

1.0.2
latest
Source
npmnpm
Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

Botmaster Session Ware Redis Store

Build Status Coverage Status npm-version license

This is the Redis store adapter for the botmaster-session-ware middleware.

Install

yarn add botmaster-session-ware-redis-store

or with npm

npm install --save botmaster-session-ware-redis-store

Note

This package is an adapter for botmaster-session-ware: https://github.com/botmasterai/botmaster-session-ware

API

RedisStore

Using this adapter along with the botmaster-session-ware middleware will store sessions in redis rather than use the default in memory store which should not be used in production

Parameters

  • redisSettings
  • settings object just a valid ioredis settings object as per: https://github.com/luin/ioredis which is used under the hood. By default, will connect to 127.0.0.1:6379 *

Examples

const Botmaster = require('botmaster');
// Using this socket.io bot class for the sake of the example
const SocketioBot = require('botmaster-socket.io');
const SessionWare = require('botmaster-session-ware');
const SessionWareRedisStore = require('botmaster-session-ware-redis-store');

const botmaster = new Botmaster();
botmaster.addBot(new SocketioBot({
  id: 'botId',
  server: botmaster.server,
}));

// declaring middleware

botmaster.use({
  type: 'incoming',
  name: 'my-awesome-middleware',
  controller: async (bot, update) => {
    // this will be {} on the first call from a certain user
    // and will contain the last message upon all the next iterations
    console.log(update.session);

    update.session.lastMessage = update.message;
  }
})

// This will make our context persist throughout different messages from the
// same user
const sessionWare = new SessionWare({ adapter: new SessionWareRedisStore() });
botmaster.useWrapped(sessionWare.incoming, sessionWare.outgoing);

get

Get or create a session with the id.

Parameters

  • id String a unique id for the session

Returns Promise evaluates to an object that is the session

set

Update a session in the storage.

Parameters

  • id String a unique id for the session
  • value Object the new value for the session

Returns Promise resolves when the session has been saved

Keywords

bot

FAQs

Package last updated on 22 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.