-
Notifications
You must be signed in to change notification settings - Fork 102
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
Add tutorial for Cloudflare Workers with Deno #754
Conversation
The relevant discussion in the chat started at https://t.me/grammyjs/122790 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much!
Ideally, instead of having a tutorial for Service Workers with Node and separate one for Module Workers with Deno, we'd only have one tutorial for Module Workers which explains how to set things up for either Deno or Node. We do not need a tutorial for Service Workers. Do you think this is possible? :)
c2d0524
to
cdd41a8
Compare
Hi all! I've pushed a few suggested changes. I would like to disagree on the opinion that both approaches are that similar so they could be merged into "one page". What they have in common is that both use "CloudFlare Workers" and GrammY and that's it. I'd like to leave it to those who actually want to use the Nodejs approach to prove me wrong. If someone comes up with a working Nodejs example I'll happily give it a second look again and try to merge things. Just let me know. For now I consider that out of scope for my PR. Kind regards |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to disagree on the opinion that both approaches are that similar so they could be merged into "one page". What they have in common is that both use "CloudFlare Workers" and GrammY and that's it.
I just tried to setup things the Nodejs way as described here and I actually failed. From my perspective both approaches are different enough to give each of them an isolated space as to not confuse the newbie developer. The Nodejs approach contains so much boilerplate that the Deno approach would just get lost between the Nodejs noise.
Alright, then let's leave it separate for now. If we find a good way to merge the guides, we can do this in a subsequent pull request.
I have a few smaller comments, but otherwise this LGTM:
10d2cbc
to
c2e87a1
Compare
Hi all! I implemented/added the requested changes and cleaned up the branch a bit. Please have a look if it works for you now. Kind regards |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just a few minor improvements below.
60c9b93
to
90614db
Compare
Added requested changes, squashed and pushed. LGTM? ;-) |
Co-authored-by: Ciki Momogi <cikimomogi@protonmail.com> Co-authored-by: KnorpelSenf <shtrog@gmail.com>
90614db
to
120e7f0
Compare
Updated Co-Authors. |
Sorry for the delay, will leave a review in the coming days! |
Will review after you. |
Friendly reminder, @KnorpelSenf. ;) |
|
||
[Cloudflare Workers](https://workers.cloudflare.com/) is a public serverless computing platform that offers a convenient and simple solution for running small workloads at the [edge](https://en.wikipedia.org/wiki/Edge_computing). | ||
|
||
This guide will take you through the process of hosting your Telegram bot on Cloudflare Workers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This guide will take you through the process of hosting your Telegram bot on Cloudflare Workers. | |
This guide will take you through the process of hosting your bot on Cloudflare Workers. |
This guide will take you through the process of hosting your Telegram bot on Cloudflare Workers. | ||
|
||
:::tip Looking for the Node.js Version? | ||
This tutorial explains how to deploy a Telegram bot to Cloudflare Workers using Deno. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tutorial explains how to deploy a Telegram bot to Cloudflare Workers using Deno. | |
This tutorial explains how to deploy a Telegram bot to Cloudflare Workers using Deno. |
:::tip Looking for the Node.js Version? | ||
This tutorial explains how to deploy a Telegram bot to Cloudflare Workers using Deno. | ||
If you're looking for the Node.js version, please check out [this tutorial](./cloudflare-workers.md) instead. | ||
::: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
::: | |
::: |
|
||
## Prerequisites | ||
|
||
To follow along, please make sure that you have a [Cloudflare account](https://dash.cloudflare.com/login) with your workers subdomain [configured](https://dash.cloudflare.com/?account=workers). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To follow along, please make sure that you have a [Cloudflare account](https://dash.cloudflare.com/login) with your workers subdomain [configured](https://dash.cloudflare.com/?account=workers). | |
To follow along, please make sure that you have a [Cloudflare account](https://dash.cloudflare.com/login) with your Workers subdomain [configured](https://dash.cloudflare.com/?account=workers). |
|
||
## Deploying Your Bot | ||
|
||
It's as easy as running: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
“It’s” is a little hard to pronounce here.
It's as easy as running: | |
It is as easy as running: |
|
||
[Cloudflare Workers](https://workers.cloudflare.com/) is a public serverless computing platform that offers a convenient and simple solution for running JavaScript at the [edge](https://en.wikipedia.org/wiki/Edge_computing). | ||
Having the ability to handle HTTP traffic and being based on the [Service Worker API](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API), building Telegram bots becomes a breeze. | ||
In addition, you can even develop [Web Apps](https://core.telegram.org/bots/webapps) at the edge, all for free within certain quotas. | ||
|
||
This guide will take you through the process of hosting your Telegram bots on Cloudflare Workers. | ||
|
||
:::tip Looking for the Deno Version? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:::tip Looking for the Deno Version? | |
:::tip Looking for the Deno Version? | |
:::tip Looking for the Deno Version? | ||
This tutorial explains how to deploy a Telegram bot to Cloudflare Workers using Node.js. | ||
If you're looking for the Deno version, please check out [this tutorial](./cloudflare-workers-deno.md) instead. | ||
::: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
::: | |
::: |
@@ -1,11 +1,16 @@ | |||
# Hosting: Cloudflare Workers | |||
# Hosting: Cloudflare Workers (Node) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Hosting: Cloudflare Workers (Node) | |
# Hosting: Cloudflare Workers (Node.js) |
@@ -358,9 +358,13 @@ export const localeEn: LocaleConfig<DefaultThemeLocaleData> = { | |||
link: "/hosting/supabase.html", | |||
}, | |||
{ | |||
text: "Cloudflare Workers", | |||
text: "Cloudflare Workers (Node)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
text: "Cloudflare Workers (Node)", | |
text: "Cloudflare Workers (Node.js)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we should use the old link to refer to the Deno guide, and then make a new page for Node.js? Deno tooling is far superior, so it makes sense to guide people there.
Whoopsie, that was optimistic. I did not forget about this, though. I'll come back to it tomorrow when I review #766, too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few details, this is really neat!
@@ -358,9 +358,13 @@ export const localeEn: LocaleConfig<DefaultThemeLocaleData> = { | |||
link: "/hosting/supabase.html", | |||
}, | |||
{ | |||
text: "Cloudflare Workers", | |||
text: "Cloudflare Workers (Node)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we should use the old link to refer to the Deno guide, and then make a new page for Node.js? Deno tooling is far superior, so it makes sense to guide people there.
Create a new directory, and create a new file `.denoflare` in that directory. | ||
Put the following contents in the file: | ||
|
||
> Note: The "$schema" key in the following JSON code specifies a fixed version in its URL ("v0.5.11"). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> Note: The "$schema" key in the following JSON code specifies a fixed version in its URL ("v0.5.11"). | |
> Note: The "$schema" key in the following JSON code specifies a fixed version in its URL ("v0.5.12"). |
(artefacts of my late review)
|
||
```json | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/skymethod/denoflare/v0.5.11/common/config.schema.json", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"$schema": "https://raw.githubusercontent.com/skymethod/denoflare/v0.5.11/common/config.schema.json", | |
"$schema": "https://raw.githubusercontent.com/skymethod/denoflare/v0.5.12/common/config.schema.json", |
@roj1512 perhaps you can take it from here, the content is great that way IMO. We can do our style nitpicking, but otherwise I think there's nothing else to do here |
I can’t push changes. |
We want to merge this into a temporary branch for translation anyway. Might as well do it now. |
Thanks for making me remember. |
* Add tutorial for Cloudflare Workers with Deno (#754) Co-authored-by: Jens Breuer <jens.breuer@camao-tec.com> Co-authored-by: Ciki Momogi <cikimomogi@protonmail.com> Co-authored-by: KnorpelSenf <shtrog@gmail.com> * Accept suggestions * Accept suggestions * Fix menu * Move default section to Node.js * Move Deno section to default * Fix link * sync to Ukrainian * fix formatting * Space before tip Co-authored-by: Nazar Antoniuk <75927667+Nazar-Ant@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Andrii Zontov <loginmanx@gmail.com> * Update site/docs/.vitepress/configs/uk.ts * Sync #754 to Indonesian * Add line highlighting * docs(id): fix typo * docs(id): sync tip * docs(id): fix typo * Disable prev/next navigation page * Update site/docs/uk/hosting/cloudflare-workers.md * Apply suggestions from code review * Add Spanish * sync zh #837 --------- Co-authored-by: Jens Breuer <breuer.jens@gmail.com> Co-authored-by: Jens Breuer <jens.breuer@camao-tec.com> Co-authored-by: Ciki Momogi <cikimomogi@protonmail.com> Co-authored-by: KnorpelSenf <shtrog@gmail.com> Co-authored-by: Nazar Antoniuk <antonuk.nazar09@gmail.com> Co-authored-by: Nazar Antoniuk <75927667+Nazar-Ant@users.noreply.github.com> Co-authored-by: Andrii Zontov <loginmanx@gmail.com> Co-authored-by: Habemuscode <habemuscode@protonmail.com> Co-authored-by: grammyz <grammyz@users.noreply.github.com>
See title.
As discussed earlier today in the Telegram group here is what I found worked for me.
Let me know if anything needs to be fixed. I tried to follow the contribution guide to the best of my understanding.
I based my writing on what I found in cloudflare-workers.md. Thanks to the author. <3
Kind regards