Hono DO is a wrapper of Cloudflare Workers ' Durable Object, designed for Hono.
$ npm install hono-do
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!
This project is open for contributions. Feel free to open an issue or a pull request! Contributing Guide for more information.