Skip to content

Commit

Permalink
Use "std/http" adapter for Vercel Edge Functions, instead of "https"
Browse files Browse the repository at this point in the history
  • Loading branch information
Hth4nh authored Dec 11, 2024
1 parent 4be90bc commit 5c00e60
Show file tree
Hide file tree
Showing 12 changed files with 179 additions and 125 deletions.
40 changes: 20 additions & 20 deletions site/docs/es/guide/deployment-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,26 +258,26 @@ El segundo parámetro pasado a `webhookCallback` ([API reference](/ref/core/webh
Debido a cómo funciona este enfoque, normalmente necesitamos un adaptador para cada framework pero, dado que algunos frameworks comparten una interfaz similar, hay adaptadores que se sabe que funcionan con múltiples frameworks.
A continuación se muestra una tabla con los adaptadores disponibles actualmente, los frameworks o APIs con los que se sabe que funcionan y los tiempos de ejecución en los que están disponibles.

| Adapter | Framework/API/Runtime |
| ------------------ | ------------------------------------------------------------------------------ |
| `aws-lambda` | AWS Lambda Functions |
| `aws-lambda-async` | AWS Lambda Functions with `async`/`await` |
| `azure` | Azure Functions |
| `bun` | `Bun.serve` |
| `cloudflare` | Cloudflare Workers |
| `cloudflare-mod` | Cloudflare Module Workers |
| `express` | Express, Google Cloud Functions |
| `fastify` | Fastify |
| `hono` | Hono |
| `http`, `https` | Node.js `http`/`https` modules, Vercel |
| `koa` | Koa |
| `next-js` | Next.js |
| `nhttp` | NHttp |
| `oak` | Oak |
| `serveHttp` | `Deno.serveHttp` |
| `std/http` | `Deno.serve`, `std/http`, `Deno.upgradeHttp`, `Fresh`, `Ultra`, `Rutt`, `Sift` |
| `sveltekit` | SvelteKit |
| `worktop` | Worktop |
| Adapter | Framework/API/Runtime |
| ------------------ | ----------------------------------------------------------------------------------------------------|
| `aws-lambda` | AWS Lambda Functions |
| `aws-lambda-async` | AWS Lambda Functions with `async`/`await` |
| `azure` | Azure Functions |
| `bun` | `Bun.serve` |
| `cloudflare` | Cloudflare Workers |
| `cloudflare-mod` | Cloudflare Module Workers |
| `express` | Express, Google Cloud Functions |
| `fastify` | Fastify |
| `hono` | Hono |
| `http`, `https` | Node.js `http`/`https` modules, Vercel Serverless |
| `koa` | Koa |
| `next-js` | Next.js |
| `nhttp` | NHttp |
| `oak` | Oak |
| `serveHttp` | `Deno.serveHttp` |
| `std/http` | `Deno.serve`, `std/http`, `Deno.upgradeHttp`, `Fresh`, `Ultra`, `Rutt`, `Sift`, Vercel Edge Runtime |
| `sveltekit` | SvelteKit |
| `worktop` | Worktop |

### Webhook Reply

Expand Down
11 changes: 10 additions & 1 deletion site/docs/es/hosting/vercel.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,21 @@ Puedes seguir usando el paquete principal de grammY y un número de plugins, per

Actualmente, no tenemos una lista completa de plugins compatibles, así que tienes que probarlo por ti mismo.

Añada esta línea al fragmento anterior si desea cambiar a Edge Functions:
Utilice este fragmento a continuación si desea cambiar a Edge Functions:

```ts
import { Bot, webhookCallback } from "grammy";

const token = process.env.BOT_TOKEN;
if (!token) throw new Error("Falta BOT_TOKEN.");

const bot = new Bot(token);

export const config = {
runtime: "edge",
};

export default webhookCallback(bot, "std/http");
```

:::
Expand Down
40 changes: 20 additions & 20 deletions site/docs/guide/deployment-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,26 +257,26 @@ The second parameter passed to `webhookCallback` ([API reference](/ref/core/webh
Because of how this approach works, we usually need an adapter for each framework but, since some frameworks share a similiar interface, there are adapters that are known to work with multiple frameworks.
Below is a table containing the currently available adapters, and the framework, APIs, or runtimes they are known to work with.

| Adapter | Framework/API/Runtime |
| ------------------ | ------------------------------------------------------------------------------ |
| `aws-lambda` | AWS Lambda Functions |
| `aws-lambda-async` | AWS Lambda Functions with `async`/`await` |
| `azure` | Azure Functions |
| `bun` | `Bun.serve` |
| `cloudflare` | Cloudflare Workers |
| `cloudflare-mod` | Cloudflare Module Workers |
| `express` | Express, Google Cloud Functions |
| `fastify` | Fastify |
| `hono` | Hono |
| `http`, `https` | Node.js `http`/`https` modules, Vercel |
| `koa` | Koa |
| `next-js` | Next.js |
| `nhttp` | NHttp |
| `oak` | Oak |
| `serveHttp` | `Deno.serveHttp` |
| `std/http` | `Deno.serve`, `std/http`, `Deno.upgradeHttp`, `Fresh`, `Ultra`, `Rutt`, `Sift` |
| `sveltekit` | SvelteKit |
| `worktop` | Worktop |
| Adapter | Framework/API/Runtime |
| ------------------ | ----------------------------------------------------------------------------------------------------|
| `aws-lambda` | AWS Lambda Functions |
| `aws-lambda-async` | AWS Lambda Functions with `async`/`await` |
| `azure` | Azure Functions |
| `bun` | `Bun.serve` |
| `cloudflare` | Cloudflare Workers |
| `cloudflare-mod` | Cloudflare Module Workers |
| `express` | Express, Google Cloud Functions |
| `fastify` | Fastify |
| `hono` | Hono |
| `http`, `https` | Node.js `http`/`https` modules, Vercel Serverless |
| `koa` | Koa |
| `next-js` | Next.js |
| `nhttp` | NHttp |
| `oak` | Oak |
| `serveHttp` | `Deno.serveHttp` |
| `std/http` | `Deno.serve`, `std/http`, `Deno.upgradeHttp`, `Fresh`, `Ultra`, `Rutt`, `Sift`, Vercel Edge Runtime |
| `sveltekit` | SvelteKit |
| `worktop` | Worktop |

### Webhook Reply

Expand Down
11 changes: 10 additions & 1 deletion site/docs/hosting/vercel.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,21 @@ You can still use the core grammY package and a number of plugins, but others ma

Currently, we don't have a comprehensive list of compatible plugins, so you need to test it by yourself.

Add this line to snippet above if you want to switch to Edge Functions:
Use this snippet below if you want to switch to Edge Functions:

```ts
import { Bot, webhookCallback } from "grammy";

const token = process.env.BOT_TOKEN;
if (!token) throw new Error("BOT_TOKEN is unset");

const bot = new Bot(token);

export const config = {
runtime: "edge",
};

export default webhookCallback(bot, "std/http");
```

:::
Expand Down
40 changes: 20 additions & 20 deletions site/docs/id/guide/deployment-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,26 +263,26 @@ Karena menggunakan pendekatan dengan cara tersebut, biasanya kita membutuhkan se
Tetapi, berhubung beberapa framework memiliki interface yang mirip, kita bisa menggunakan adapter yang sama untuk beberapa framework sekaligus.
Di bawah ini adalah tabel berisi berbagai macam adapter yang tersedia beserta jenis framework, API, dan runtime yang diketahui berfungsi dengan baik di grammY.

| Adapter | Framework/API/Runtime |
| ------------------ | ------------------------------------------------------------------------------ |
| `aws-lambda` | AWS Lambda Functions |
| `aws-lambda-async` | AWS Lambda Functions dengan `async`/`await` |
| `azure` | Azure Functions |
| `bun` | `Bun.serve` |
| `cloudflare` | Cloudflare Workers |
| `cloudflare-mod` | Cloudflare Module Workers |
| `express` | Express, Google Cloud Functions |
| `fastify` | Fastify |
| `hono` | Hono |
| `http`, `https` | Node.js `http`/`https` modules, Vercel |
| `koa` | Koa |
| `next-js` | Next.js |
| `nhttp` | NHttp |
| `oak` | Oak |
| `serveHttp` | `Deno.serveHttp` |
| `std/http` | `Deno.serve`, `std/http`, `Deno.upgradeHttp`, `Fresh`, `Ultra`, `Rutt`, `Sift` |
| `sveltekit` | SvelteKit |
| `worktop` | Worktop |
| Adapter | Framework/API/Runtime |
| ------------------ | ----------------------------------------------------------------------------------------------------|
| `aws-lambda` | AWS Lambda Functions |
| `aws-lambda-async` | AWS Lambda Functions with `async`/`await` |
| `azure` | Azure Functions |
| `bun` | `Bun.serve` |
| `cloudflare` | Cloudflare Workers |
| `cloudflare-mod` | Cloudflare Module Workers |
| `express` | Express, Google Cloud Functions |
| `fastify` | Fastify |
| `hono` | Hono |
| `http`, `https` | Node.js `http`/`https` modules, Vercel Serverless |
| `koa` | Koa |
| `next-js` | Next.js |
| `nhttp` | NHttp |
| `oak` | Oak |
| `serveHttp` | `Deno.serveHttp` |
| `std/http` | `Deno.serve`, `std/http`, `Deno.upgradeHttp`, `Fresh`, `Ultra`, `Rutt`, `Sift`, Vercel Edge Runtime |
| `sveltekit` | SvelteKit |
| `worktop` | Worktop |

### Webhook Reply

Expand Down
11 changes: 10 additions & 1 deletion site/docs/id/hosting/vercel.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,21 @@ Meski kamu masih bisa menggunakan paket inti grammY dan sejumlah plugin lainnya,

Saat ini, kami tidak memiliki daftar lengkap plugin yang kompatibel, sehingga kamu perlu mencobanya sendiri.

Tambahkan baris ini pada kode di atas jika kamu ingin beralih ke Edge Functions:
Gunakan cuplikan di bawah ini jika Anda ingin beralih ke Fungsi Edge:

```ts
import { Bot, webhookCallback } from "grammy";

const token = process.env.BOT_TOKEN;
if (!token) throw new Error("BOT_TOKEN belum diisi");

const bot = new Bot(token);

export const config = {
runtime: "edge",
};

export default webhookCallback(bot, "std/http");
```

:::
Expand Down
Loading

0 comments on commit 5c00e60

Please sign in to comment.