A fullstack app for indexing standard.site documents
1import { Hono } from "hono";
2import type { Bindings } from "../types";
3
4const jetstream = new Hono<{ Bindings: Bindings }>();
5
6function getStub(env: Bindings) {
7 const id = env.JETSTREAM_CONSUMER.idFromName("singleton");
8 return env.JETSTREAM_CONSUMER.get(id);
9}
10
11jetstream.get("/start", async (c) => {
12 const stub = getStub(c.env);
13 const resp = await stub.fetch(new Request("http://do/start"));
14 return c.json(await resp.json());
15});
16
17jetstream.get("/status", async (c) => {
18 const stub = getStub(c.env);
19 const resp = await stub.fetch(new Request("http://do/status"));
20 return c.json(await resp.json());
21});
22
23jetstream.get("/stop", async (c) => {
24 const stub = getStub(c.env);
25 const resp = await stub.fetch(new Request("http://do/stop"));
26 return c.json(await resp.json());
27});
28
29export default jetstream;