Skip to content

Commit

Permalink
chore: improve README
Browse files Browse the repository at this point in the history
  • Loading branch information
kravetsone committed Apr 11, 2024
1 parent a0e16c9 commit ff404a7
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Session plugin for GramIO.

**!!!Currently not optimized!!!**
**!!!Currently not optimized and WIP!!!**

## Usage

Expand All @@ -25,6 +25,8 @@ const bot = new Bot(process.env.token!)
bot.start();
```

You can use this plugin with any storage ([Read more](https://gramio.netlify.app/storages/))

### Redis example

[More info](https://github.com/gramiojs/storages/tree/master/packages/redis)
Expand All @@ -49,3 +51,21 @@ const bot = new Bot(process.env.token!)

bot.start();
```

### TypeScript

To **type** a session data, you need to specify the type as the `ReturnType` of the initial function.

```ts
interface MySessionData {
apple: number;
some?: "maybe-empty";
}

bot.extend(
session({
key: "sessionKey",
initial: (): MySessionData => ({ apple: 1 }),
})
);
```

0 comments on commit ff404a7

Please sign in to comment.