hono-do
hono-do copied to clipboard
A wrapper of Cloudflare Workers's Durable Object for Hono.
Hono for Durable Object
Hono DO is a wrapper of Cloudflare Workers ' Durable Object, designed for Hono.
[!IMPORTANT] Cloudflare released 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.
$ npm install hono-do
Usage
export const Counter = generateHonoObject("/counter", async (app, state) => {
const { storage } = state;
let value = (await storage.get<number>("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!
Support
- [x] Alarm API
- [x] Hibernation Websocket API
License
MIT
Contributing
This project is open for contributions. Feel free to open an issue or a pull request! Contributing Guide for more information.