Verifying solutions in Node.js

1. Install and import the @botpoison/node library.
npm install @botpoison/node
2. Create a new Botpoison instance with your private key.
3. Verify the solution using the verify() function.
javascript
// 1. Import the library
import Botpoison from "@botpoison/node";
// or const Botpoison = require("@botpoison/node")
// 2. Create a new instance with your secret key
const botpoison = new Botpoison({
secretKey: "sk_xxxxxxxx"
});
server.post('/message', async (req, res) => {
const { message, _botpoison } = req.body;
// 3. Verify the solution
const { ok } = await botpoison.verify(_botpoison );
if(!ok) {
throw new Error('Invalid Botpoison solution')
}
else {
// ...
}
})