-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fastify example #29
Comments
@gomez-git could you take a look at #30 and leave an approval there if you could make it work? |
I think about this one import { Bot, webhookCallback } from 'grammy';
import fastify from 'fastify';
import ngrok from '@ngrok/ngrok';
const { BOT_TOKEN, PORT, SECRET_TOKEN } = process.env;
const bot = new Bot(BOT_TOKEN);
bot.on('message:text', (ctx) => ctx.reply(ctx.message.text));
const server = fastify();
server.post('/webhook', webhookCallback(bot, 'fastify', { secretToken: SECRET_TOKEN }));
server.listen({ port: +PORT }, async (err, address) => {
if (err) {
console.error(err);
process.exit(1);
}
const url = await ngrok.connect(+PORT);
await bot.api.setWebhook(`${url}/webhook`, { secret_token: SECRET_TOKEN });
}); |
Perhaps we should use the official package https://www.npmjs.com/package/@ngrok/ngrok instead? |
I use it in my snippet, isn't it? |
No. You're using https://github.com/bubenshchykov/ngrok. See https://t.me/grammyjs/166618. |
@KnorpelSenf They are importing |
Oh what |
I'm blind |
Yes, let's do that. @AbbassAlmusawi could you update your code in #30 with the above package? I'll merge after that. |
Dockerfile FROM node:18-alpine
WORKDIR /usr/src
COPY ./package*.json ./
EXPOSE 443
RUN npm ci
COPY . ./
CMD ["ts-node", "fastify-ngrok-webhook.ts"] .dockerignore
command docker build --tag grammy_fastify_example .
docker run --detach \
--name grammy_fe \
-e BOT_TOKEN='' \
-e PORT='' \
-e SECRET_TOKEN='' \
grammy_fastify_example
|
Done, please see #30 and tell me if there are any mistakes of suggestions |
Can you please add an example using webhook with secret_token, ngrok and fastify? I spent too much time trying to get it to work.
Try to use express v4.18.2, it didn't handle errors..
Originally posted by @gomez-git in grammyjs/grammY#486 (comment)
The text was updated successfully, but these errors were encountered: