Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sor4chi/hono-do
A wrapper of Cloudflare Workers's Durable Object for Hono.
https://github.com/sor4chi/hono-do
cloudflare durable-objects hono workers
Last synced: 24 days ago
JSON representation
A wrapper of Cloudflare Workers's Durable Object for Hono.
- Host: GitHub
- URL: https://github.com/sor4chi/hono-do
- Owner: sor4chi
- License: mit
- Created: 2023-09-18T08:17:36.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-07-08T15:14:14.000Z (7 months ago)
- Last Synced: 2024-12-29T07:13:05.467Z (about 1 month ago)
- Topics: cloudflare, durable-objects, hono, workers
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/hono-do
- Size: 316 KB
- Stars: 83
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Hono for Durable Object
Hono DO is a wrapper of [Cloudflare Workers](https://workers.cloudflare.com/) ' [Durable Object](https://developers.cloudflare.com/workers/learning/using-durable-objects), designed for [Hono](https://hono.dev/).
> [!IMPORTANT]
> Cloudflare released [RPC](https://developers.cloudflare.com/workers/runtime-apis/rpc/) feature, which is a better way to communicate between Durable Objects.
> This library was developed to improve the developer experience for Durable Objects when RPC was not yet available.
> So, please consider it before using this library.```bash
$ npm install hono-do
```## Usage
```typescript
export const Counter = generateHonoObject("/counter", async (app, state) => {
const { storage } = state;
let value = (await storage.get("value")) ?? 0;app.post("/increment", (c) => {
storage.put("value", value++);
return c.text(value.toString());
});app.post("/decrement", (c) => {
storage.put("value", value--);
return c.text(value.toString());
});app.get("/", (c) => {
return c.text(value.toString());
});
});
```You want to find more? Check out the [examples](./examples)!
## Support
- [x] [Alarm API](https://developers.cloudflare.com/durable-objects/api/alarms/)
- [x] [Hibernation Websocket API](https://developers.cloudflare.com/durable-objects/learning/websockets/#websocket-hibernation)## License
[MIT](./LICENSE)
## Contributing
This project is open for contributions. Feel free to open an issue or a pull request!
[Contributing Guide](./CONTRIBUTING.md) for more information.