I developed a chatbot using the Telegraf.js framework. Although the latest version of Telegraf offers TypeScript support, I chose to use JavaScript. I followed a tutorial to deploy it and would like to know if there are any security vulnerabilities that can be addressed.
The files involved in the project are as follows:
path: src/bot.js
import { Telegraf } from 'telegraf'
const bot = new Telegraf(process.env.BOT_TOKEN)
bot.start((ctx) => ctx.reply('Welcome'))
export default bot
path: api/index.js
import bot from '../src/bot.js';
export default async function handler(req, res) {
if (req.method === 'POST') {
try {
await bot.handleUpdate(req.body)
res.status(200).send('OK')
} catch (err) {
console.error('Erro ao lidar com update:', err)
res.status(500).send('Erro interno')
}
} else {
res.status(200).send('Bot do Telegram está rodando com webhook!')
}
}
path: ./vercel.json
{
"version": 2,
"builds": [
{ "src": "api/index.js", "use": "@vercel/node" }
],
"routes": [
{ "src": "/.*", "dest": "api/index.js" }
]
}
The deployment was successful; however, I’d like to know if there are any security issues that should be addressed.