Closed sor4chi closed 7 months ago
I want to add new syntax for less code.
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()); }); });
So far the code had to be written like this
app.all("/counter/*", (c) => { const id = c.env.COUNTER.idFromName("Counter"); const obj = c.env.COUNTER.get(id); return obj.fetch(c.req.raw); });
I plan to add a new syntax like
app.do(Counter, "Counter")
app.do() is extended by Hono. The first args is Hono Object, and The second args is the value of idFromName().
app.do()
idFromName()
I want to add new syntax for less code.
So far the code had to be written like this
I plan to add a new syntax like
app.do()
is extended by Hono. The first args is Hono Object, and The second args is the value ofidFromName()
.