Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
@grammyjs/storage-prisma
Advanced tools
Storage adapter that can be used to store your session data with Prisma when using sessions.
npm install @grammyjs/storage-prisma --save
You can check the examples folder, or simply use followed code:
Implement the Session model in your Prisma schema:
model Session {
id Int @id @default(autoincrement())
key String @unique
value String
}
The
id
field is not needed for this adapter to work.The only restriction is that
key
must be aString
index, either by adding the@unique
keyword or the@id
keyword, andvalue
must be aString
.
Generate Prisma client using the terminal:
npx prisma generate
Migrate the schema changes to your database:
npx prisma db push
# or
npx prisma migrate dev
Create bot and pass adapter as storage:
import { Bot, Context, session, SessionFlavor } from "grammy";
import { PrismaAdapter } from "@grammyjs/storage-prisma";
import { PrismaClient } from "@prisma/client";
// Create Prisma client
const prisma = new PrismaClient();
// write session types
interface SessionData {
counter: number;
}
// create context for grammy instance
type MyContext = Context & SessionFlavor<SessionData>;
// Create bot and register session middleware
async function bootstrap() {
const bot = new Bot<MyContext>("");
bot.use(
session({
initial: () => ({ counter: 0 }),
storage: new PrismaAdapter(prisma.session),
})
);
// Register your usual middleware, and start the bot
bot.command("stats", (ctx) =>
ctx.reply(`Already got ${ctx.session.counter} photos!`)
);
bot.on(":photo", (ctx) => ctx.session.counter++);
bot.start();
}
2.1.0 (2023-01-16)
denodb
dependency to github version instead of released one (7bc7095)FAQs
Prisma storage for grammY
The npm package @grammyjs/storage-prisma receives a total of 177 weekly downloads. As such, @grammyjs/storage-prisma popularity was classified as not popular.
We found that @grammyjs/storage-prisma demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.