Skip to content

Commit

Permalink
Add framework adapters (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
amberlionk authored Oct 18, 2021
1 parent c342b85 commit 0a3a7cc
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
7 changes: 5 additions & 2 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@
"plugin",
"doc",
"example",
"review"
"review",
"mentoring"
]
},
{
Expand Down Expand Up @@ -239,7 +240,9 @@
"avatar_url": "https://avatars.githubusercontent.com/u/4936805?v=4",
"profile": "https://github.com/dzek69",
"contributions": [
"doc"
"doc",
"code",
"bug"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ It solves this problem substantially better by providing a Deno-aware wrapper of
Hence, you can write a Deno project and directly compile it to JavaScript files that run under Node.js.

In other words, working on grammY effectively means work on a Deno project.
We use Deno testing, Deno linting, and the [Deno extension](https://marketplace.visualstudio.com/items?itemName=denoland.vscode-deno) for VSCode.
You usual TypeScript tooling does not work—and once you tried developing for Deno, you know that this is a good thing.
We use Deno testing, Deno linting, Deno formatting, and the [Deno extension](https://marketplace.visualstudio.com/items?itemName=denoland.vscode-deno) for VSCode.
Your usual TypeScript tooling does not work—and once you tried developing for Deno and you have experienced how superior the development experience is, you will know why we are happy about our choice.

> Note that not all plugins of grammY have to have the same setup: many of them only integrate with grammY itself, and hence can be written for Node and automatically ported to Deno via <https://skypack.dev/> and similar services.
Expand All @@ -42,7 +42,7 @@ There are several areas of contributions, and they have different ways to get yo
There are both official plugins and third-party plugins.
Our official plugins need to be of high quality (100 % TypeScript, ES6, Deno support, docs that are on par with grammY, semver, etc).
Third-party plugins are independent and anyone can do them however they want.
If a third-party plugins was to be listed on the website, some docs would be nice.
If a third-party plugin was to be listed on the website, some docs would be nice.
- **Storage adapters.**
Please send a message to the [group chat](https://telegram.me/grammyjs) if you want to create an offical storage adapter for the [session plugin](https://grammy.dev/plugins/session.html).
You will be granted all necessary permissions, and the repository will be listed [here](https://grammy.dev/plugins/session.html#official).
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center"><a href="https://github.com/wojpawlik"><img src="https://avatars.githubusercontent.com/u/23058303?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Wojciech Pawlik</b></sub></a><br /><a href="#ideas-wojpawlik" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Awojpawlik" title="Reviewed Pull Requests">👀</a> <a href="#infra-wojpawlik" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#platform-wojpawlik" title="Packaging/porting to new platform">📦</a></td>
<td align="center"><a href="https://github.com/MegaITA"><img src="https://avatars.githubusercontent.com/u/32493080?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Alessandro Bertozzi</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=MegaITA" title="Documentation">📖</a></td>
<td align="center"><a href="https://trgwii.no/"><img src="https://avatars.githubusercontent.com/u/11262022?v=4?s=100" width="100px;" alt=""/><br /><sub><b>trgwii</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=trgwii" title="Code">💻</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Atrgwii" title="Reviewed Pull Requests">👀</a></td>
<td align="center"><a href="/KnightNiwrem"><img src="https://avatars.githubusercontent.com/u/9781814?v=4?s=100" width="100px;" alt=""/><br /><sub><b>KnightNiwrem</b></sub></a><br /><a href="/grammyjs/grammY/commits?author=KnightNiwrem" title="Code">💻</a> <a href="/grammyjs/grammY/issues?q=author%3AKnightNiwrem" title="Bug reports">🐛</a> <a href="#plugin-KnightNiwrem" title="Plugin/utility libraries">🔌</a> <a href="/grammyjs/grammY/commits?author=KnightNiwrem" title="Documentation">📖</a> <a href="#example-KnightNiwrem" title="Examples">💡</a> <a href="/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3AKnightNiwrem" title="Reviewed Pull Requests">👀</a></td>
<td align="center"><a href="/KnightNiwrem"><img src="https://avatars.githubusercontent.com/u/9781814?v=4?s=100" width="100px;" alt=""/><br /><sub><b>KnightNiwrem</b></sub></a><br /><a href="/grammyjs/grammY/commits?author=KnightNiwrem" title="Code">💻</a> <a href="/grammyjs/grammY/issues?q=author%3AKnightNiwrem" title="Bug reports">🐛</a> <a href="#plugin-KnightNiwrem" title="Plugin/utility libraries">🔌</a> <a href="/grammyjs/grammY/commits?author=KnightNiwrem" title="Documentation">📖</a> <a href="#example-KnightNiwrem" title="Examples">💡</a> <a href="/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3AKnightNiwrem" title="Reviewed Pull Requests">👀</a> <a href="#mentoring-KnightNiwrem" title="Mentoring">🧑‍🏫</a></td>
<td align="center"><a href="https://mkr.pw"><img src="https://avatars.githubusercontent.com/u/19621208?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Muthu Kumar</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3AMKRhere" title="Reviewed Pull Requests">👀</a></td>
</tr>
<tr>
Expand All @@ -140,7 +140,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center"><a href="https://github.com/deptyped"><img src="https://avatars.githubusercontent.com/u/26162440?v=4?s=100" width="100px;" alt=""/><br /><sub><b>deptyped</b></sub></a><br /><a href="#example-deptyped" title="Examples">💡</a> <a href="https://github.com/grammyjs/grammY/commits?author=deptyped" title="Documentation">📖</a> <a href="#tutorial-deptyped" title="Tutorials">✅</a></td>
</tr>
<tr>
<td align="center"><a href="/dzek69"><img src="https://avatars.githubusercontent.com/u/4936805?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jacek Nowacki</b></sub></a><br /><a href="/grammyjs/grammY/commits?author=dzek69" title="Documentation">📖</a></td>
<td align="center"><a href="/dzek69"><img src="https://avatars.githubusercontent.com/u/4936805?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jacek Nowacki</b></sub></a><br /><a href="/grammyjs/grammY/commits?author=dzek69" title="Documentation">📖</a> <a href="/grammyjs/grammY/commits?author=dzek69" title="Code">💻</a> <a href="/grammyjs/grammY/issues?q=author%3Adzek69" title="Bug reports">🐛</a></td>
<td align="center"><a href="https://blog.outv.im"><img src="https://avatars.githubusercontent.com/u/19144373?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Outvi V</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=outloudvi" title="Code">💻</a></td>
<td align="center"><a href="https://bandism.net/"><img src="https://avatars.githubusercontent.com/u/22633385?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ikko Ashimine</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=eltociear" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/amberlionk"><img src="https://avatars.githubusercontent.com/u/29119723?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Yevhen Denesiuk</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Aamberlionk" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/grammyjs/grammY/issues?q=author%3Aamberlionk" title="Bug reports">🐛</a></td>
Expand Down
18 changes: 17 additions & 1 deletion src/convenience/webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ type SupportedFrameworks =
| "koa"
| "oak"
| "fastify"
| "worktop";
| "worktop"
| "callback"
| "aws-api-lambda";

/**
* Abstraction over a request-response cycle, provding access to the update, as
Expand Down Expand Up @@ -71,13 +73,27 @@ const frameworkAdapters: Record<SupportedFrameworks, FrameworkAdapter> = {
}),
fastify: (req, reply) => ({
update: Promise.resolve(req.body),
end: () => reply.send({}),
respond: (json) => reply.send(json),
}),
worktop: (req, res) => ({
update: Promise.resolve(req.body.json()),
end: () => res.end(),
respond: (json) => res.send(200, json),
}),
callback: (update, callback) => ({
update: update,
respond: callback,
}),
"aws-api-lambda": (event, _context, callback) => ({
update: JSON.parse(event.body),
end: () => callback(null, { statusCode: 200 }),
respond: (json) =>
callback(null, {
statusCode: 200,
body: json
}),
})
// please open a PR if you want to add another
};

Expand Down

0 comments on commit 0a3a7cc

Please sign in to comment.