Skip to content

Commit

Permalink
Merge branch 'main' into handle-no-payload
Browse files Browse the repository at this point in the history
  • Loading branch information
KnorpelSenf authored Nov 12, 2024
2 parents 42b7cb4 + 7d20285 commit 5b850b5
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 2 deletions.
20 changes: 20 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -1475,6 +1475,26 @@
"ideas",
"code"
]
},
{
"login": "BilagoNet",
"name": "Oyatillo",
"avatar_url": "https://avatars.githubusercontent.com/u/105904746?v=4",
"profile": "https://tilon.uz",
"contributions": [
"review",
"bug",
"code"
]
},
{
"login": "vorant94",
"name": "Mordechai Dror",
"avatar_url": "https://avatars.githubusercontent.com/u/9719319?v=4",
"profile": "https://www.vorant94.io/",
"contributions": [
"review"
]
}
]
}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center" valign="top" width="11.11%"><a href="https://github.com/ExposedCat"><img src="https://avatars.githubusercontent.com/u/44642024?v=4?s=100" width="100px;" alt="Artem Prokop"/><br /><sub><b>Artem Prokop</b></sub></a><br /><a href="#userTesting-ExposedCat" title="User Testing">📓</a></td>
<td align="center" valign="top" width="11.11%"><a href="https://chinoman10.com/"><img src="https://avatars.githubusercontent.com/u/8300763?v=4?s=100" width="100px;" alt="Sérgio Rebelo"/><br /><sub><b>Sérgio Rebelo</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3AChinoman10" title="Reviewed Pull Requests">👀</a></td>
<td align="center" valign="top" width="11.11%"><a href="https://blog.katsuba.dev"><img src="https://avatars.githubusercontent.com/u/10637135?v=4?s=100" width="100px;" alt="Igor Katsuba"/><br /><sub><b>Igor Katsuba</b></sub></a><br /><a href="#ideas-IKatsuba" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/commits?author=IKatsuba" title="Code">💻</a></td>
<td align="center" valign="top" width="11.11%"><a href="https://tilon.uz"><img src="https://avatars.githubusercontent.com/u/105904746?v=4?s=100" width="100px;" alt="Oyatillo"/><br /><sub><b>Oyatillo</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3ABilagoNet" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/grammyjs/grammY/issues?q=author%3ABilagoNet" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=BilagoNet" title="Code">💻</a></td>
</tr>
<tr>
<td align="center" valign="top" width="11.11%"><a href="https://www.vorant94.io/"><img src="https://avatars.githubusercontent.com/u/9719319?v=4?s=100" width="100px;" alt="Mordechai Dror"/><br /><sub><b>Mordechai Dror</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Avorant94" title="Reviewed Pull Requests">👀</a></td>
</tr>
</tbody>
</table>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "grammy",
"description": "The Telegram Bot Framework.",
"version": "1.31.1",
"version": "1.31.2",
"author": "KnorpelSenf",
"license": "MIT",
"engines": {
Expand Down
3 changes: 3 additions & 0 deletions src/convenience/frameworks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ const bun: BunAdapter = (request) => {
unauthorized: () => {
resolveResponse(unauthorized());
},
handlerReturn: new Promise<Response>((resolve) => {
resolveResponse = resolve;
}),
};
};

Expand Down
11 changes: 10 additions & 1 deletion src/core/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,13 @@ class ApiClient<R extends RawApi> {
) {
const apiRoot = options.apiRoot ?? "https://api.telegram.org";
const environment = options.environment ?? "prod";

// In an ideal world, `fetch` is independent of the context being called,
// but in a Cloudflare worker, any context other than global throws an error.
// That is why we need to call custom fetch or fetch without context.
const { fetch: customFetch } = options;
const fetchFn = customFetch ?? fetch;

this.options = {
apiRoot,
environment,
Expand All @@ -252,7 +259,9 @@ class ApiClient<R extends RawApi> {
},
canUseWebhookReply: options.canUseWebhookReply ?? (() => false),
sensitiveLogs: options.sensitiveLogs ?? false,
fetch: options.fetch ?? fetch,
fetch:
((...args: Parameters<typeof fetch>) =>
fetchFn(...args)) as typeof fetch,
};
this.fetch = this.options.fetch;
if (this.options.apiRoot.endsWith("/")) {
Expand Down

0 comments on commit 5b850b5

Please sign in to comment.