Socket
Socket
Sign inDemoInstall

telegraf-postgres-session

Package Overview
Dependencies
35
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.4 to 1.0.5

2

package.json
{
"name": "telegraf-postgres-session",
"version": "1.0.4",
"version": "1.0.5",
"description": "A middleware session for telegraf",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -15,4 +15,4 @@ # PostgreSQL session middleware for Telegraf

```js
const {Telegraf} = require('telegraf');
const PostgresSession = require('telegraf-postgres-session')
import { Telegraf } from 'telegraf';
import PostgresSession from 'telegraf-postgres-session';

@@ -32,6 +32,33 @@ const bot = new Telegraf(process.env.BOT_TOKEN) // Your Bot token here

ctx.reply(ctx.session.counter)
})
});
bot.launch()
bot.launch();
```
## Example with Typescript
```ts
import { Context, Telegraf } from 'telegraf';
import PostgresSession from 'telegraf-postgres-session';
interface SessionContext extends Context {
session: any;
};
const bot: Telegraf<SessionContext> = new Telegraf(process.env.BOT_TOKEN as string);// Your Bot token here
bot.use((new PostgresSession({
connectionString: process.env.DATABASE_URL,
ssl: {
rejectUnauthorized: false
}
})).middleware());
bot.on('message', ctx => {
ctx.session.counter = ctx.session.counter ? ctx.session.counter : 0
ctx.session.counter++
ctx.reply(ctx.session.counter)
});
bot.launch();
```
The database connection configuration is described in The [PostgreSQL API](https://node-postgres.com).
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc