Skip to content
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

Merged
merged 1 commit into from
Jun 30, 2023

Conversation

jebreuer
Copy link
Contributor

@jebreuer jebreuer commented Mar 23, 2023

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

@KnorpelSenf KnorpelSenf requested a review from rojvv March 23, 2023 20:05
@KnorpelSenf
Copy link
Member

The relevant discussion in the chat started at https://t.me/grammyjs/122790

Copy link
Member

@KnorpelSenf KnorpelSenf left a 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? :)

@jebreuer
Copy link
Contributor Author

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 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.

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
Jens

@jebreuer jebreuer requested review from KnorpelSenf and removed request for rojvv March 24, 2023 19:56
Copy link
Member

@KnorpelSenf KnorpelSenf left a 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:

site/docs/.vuepress/configs/en.ts Outdated Show resolved Hide resolved
site/docs/hosting/cloudflare-workers-deno.md Outdated Show resolved Hide resolved
site/docs/hosting/cloudflare-workers-deno.md Outdated Show resolved Hide resolved
@quadratz quadratz changed the base branch from main to cf-deno March 26, 2023 10:39
@jebreuer jebreuer changed the base branch from cf-deno to main March 29, 2023 17:15
@jebreuer
Copy link
Contributor Author

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
Jens

@jebreuer jebreuer requested review from KnorpelSenf and quadratz and removed request for KnorpelSenf and quadratz March 29, 2023 17:23
Copy link
Contributor

@quadratz quadratz left a 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.

site/docs/hosting/cloudflare-workers-deno.md Outdated Show resolved Hide resolved
site/docs/hosting/cloudflare-workers-deno.md Outdated Show resolved Hide resolved
site/docs/hosting/cloudflare-workers-deno.md Outdated Show resolved Hide resolved
@jebreuer
Copy link
Contributor Author

Added requested changes, squashed and pushed.

LGTM? ;-)

@jebreuer jebreuer requested review from quadratz and removed request for KnorpelSenf March 30, 2023 16:59
Co-authored-by: Ciki Momogi <cikimomogi@protonmail.com>
Co-authored-by: KnorpelSenf <shtrog@gmail.com>
@jebreuer
Copy link
Contributor Author

Updated Co-Authors.

@KnorpelSenf
Copy link
Member

Sorry for the delay, will leave a review in the coming days!

@rojvv
Copy link
Member

rojvv commented Apr 11, 2023

Will review after you.

@jebreuer
Copy link
Contributor Author

jebreuer commented May 4, 2023

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
:::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
:::
:::


## 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).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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:
Copy link
Member

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.

Suggested change
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?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
:::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.
:::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
:::
:::

@@ -1,11 +1,16 @@
# Hosting: Cloudflare Workers
# Hosting: Cloudflare Workers (Node)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# 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)",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
text: "Cloudflare Workers (Node)",
text: "Cloudflare Workers (Node.js)",

Copy link
Member

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.

@KnorpelSenf
Copy link
Member

Sorry for the delay, will leave a review in the coming days!

Whoopsie, that was optimistic. I did not forget about this, though. I'll come back to it tomorrow when I review #766, too.

Copy link
Member

@KnorpelSenf KnorpelSenf left a 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)",
Copy link
Member

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").
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> 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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"$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",

@KnorpelSenf KnorpelSenf requested a review from rojvv June 20, 2023 12:09
@KnorpelSenf
Copy link
Member

@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

@rojvv
Copy link
Member

rojvv commented Jun 21, 2023

I can’t push changes.

@rojvv rojvv mentioned this pull request Jun 21, 2023
@KnorpelSenf
Copy link
Member

We want to merge this into a temporary branch for translation anyway. Might as well do it now.

@KnorpelSenf
Copy link
Member

@roj1512 are you going to do that, or are you instead planning on waiting for @jebreuer to fix things up?

@rojvv
Copy link
Member

rojvv commented Jun 30, 2023

Thanks for making me remember.

@rojvv rojvv changed the base branch from main to 754 June 30, 2023 19:29
@rojvv rojvv added the not translatable Translator intervention is not required. label Jun 30, 2023
@rojvv rojvv merged commit 4e9030b into grammyjs:754 Jun 30, 2023
quadratz pushed a commit that referenced this pull request Jul 11, 2023
github-merge-queue bot pushed a commit that referenced this pull request Aug 3, 2023
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not translatable Translator intervention is not required.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants