grammyjs / awesome-grammY

A collection of community projects leveraging the grammY ecosystem.
Creative Commons Zero v1.0 Universal
205 stars 26 forks source link

Where should I place the missing Web Framework Adapter? #47

Open sooluh opened 6 months ago

sooluh commented 6 months ago

I just created a package for AdonisJS that makes it easy to integrate with grammY. Where should I add this package to the list?

Package name: adonisjs-grammy Repository: https://github.com/sooluh/adonisjs-grammy Description: GrammY Web Framework Adapter for AdonisJS

KnorpelSenf commented 5 months ago

Given that it is a bot, it should be added to the section Bots. You can mention AdonisJS in the description so that people have an extra reason to check out the repo.

sooluh commented 4 months ago

I think it's not a bot; it's just a library/add-on for AdonisJS (a web framework) that integrates with grammY. It's like a grammY adapter for AdonisJS that was missing. Doesn't grammY support only Express.js, Fastify, Cloudflare Workers, etc., here?

Edit: Maybe we need to add a section for "Web Framework Adapters"?

KnorpelSenf commented 4 months ago

If it was a web framework adapter, then it would only consist of 10 lines of code and they could be added straight to the grammY core library. Your repository does a lot more than that, and calling it a web framework adapter would be incorrect.

That being said, I don't really understand much of the point of your repository. Why are there so many mostly empty files with boilerplate code, if integrating grammY via webhooks only needs a fraction of the complexity? What does all the rest of the code do?

sooluh commented 4 months ago

Sorry for the confusion. My repository above is a package for AdonisJS (you can try learning about it here and here). AdonisJS is a web framework similar to Laravel but in a NodeJS environment. I looked at this page and didn't find AdonisJS, so I made it for AdonisJS.

Let's look here, this is a starter kit for creating packages in AdonisJS, maybe that includes package standardization in the AdonisJS framework, so I just follow the standards they make. I integrated it with grammY to make it easier to develop applications with the AdonisJS framework and Telegram bots using grammY.

I have read most of the grammY codebase and it is not quite feasible to integrate it into that codebase, because AdonisJS has a structure that I find unique.

I just want to support the open-source projects grammY and AdonisJS, as I use both. AdonisJS serves as a web framework that makes it easy for me to create information systems with databases, and I connect them to the Telegram bot I build with grammY.

I hope this provides enough explanation.

Edit: My package above has even been published a long time ago on the AdonisJS page: https://packages.adonisjs.com/packages/sooluh-adonisjs-grammy

KnorpelSenf commented 4 months ago

Why is it a bad idea to just do router.post("/", webhookCallback(bot, "adonis")) in your opinion?

sooluh commented 4 months ago

But how do I call the grammY instance without reinitializing it from anywhere (middleware, controller, etc.)?

Instead of making this and that myself, I made it easy with this package. Just import and call all the functions grammY has without re-initiating.

import grammy from 'adonisjs-grammy/services/main'

So people just need to create the business logic.

KnorpelSenf commented 4 months ago

without reinitializing it from anywhere (middleware, controller, etc.)

Why would you initialise it many times in the first place?

KnorpelSenf commented 4 months ago

Can you share a link to a repository that uses this? I'd still like to understand the reason for all of this complexity

sooluh commented 4 months ago

I'll send it ASAP.

I'll add a little case here. I create a form on the website and submit data, this is of course processed in the controller.

Then, I want to send a chat to the data entered with grammY. So, instead of re-initiating grammY's Bot class, just call it from the services in my package.

KnorpelSenf commented 3 months ago

Is this still a thing?