simple implementation of redis sessions for vk-io
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
Timofey Gelazoniya 9076a1c23e
Merge pull request #2 from xzeldon/dependabot/npm_and_yarn/redis-4.0.1
5 months ago
.github ci: add dependabot config 7 months ago
src initial commit 7 months ago
typings chore: add type declarations 7 months ago
.gitignore initial commit 7 months ago
LICENSE Initial commit 7 months ago
README.md docs: change packet name to name from npm registry 7 months ago
package.json chore(deps): bump redis from 3.1.2 to 4.0.0 6 months ago
yarn.lock chore(deps): bump redis from 4.0.0 to 4.0.1 5 months ago

README.md

vk-io-session-redis

vk-io-session-redis - simple implementation of the Redis sessions

Installation

Node.js 13.0.0 or newer is required

Yarn

Recommended

yarn add vk-io-session-redis

NPM

npm i vk-io-session-redis

Example usage:

import { VK } from "vk-io";
import { RedisSession } from "vk-io-session-redis";

const bot = new VK({
    token: process.env.TOKEN
});

const redisSession = new RedisSession();
bot.updates.use(redisSession.middleware());

bot.updates.on("message", (context) => {
    if (context.isOutbox) return;

    const { session } = context;

    session.counter = session.counter || 0;
    session.counter++;

    context.send(`You turned to the bot (${session.counter}) times`);
});

bot.updates.start().catch(err => console.error(err));