| 1 | import { Hono } from "hono"; |
| 2 | import { cors } from "hono/cors"; |
| 3 | import auth from "./routes/auth"; |
| 4 | import subscribe from "./routes/subscribe"; |
| 5 | import "./lib/path-redirect"; |
| 6 | |
| 7 | type Bindings = { |
| 8 | ASSETS: Fetcher; |
| 9 | SEQUOIA_SESSIONS: KVNamespace; |
| 10 | CLIENT_URL: string; |
| 11 | }; |
| 12 | |
| 13 | const app = new Hono<{ Bindings: Bindings }>(); |
| 14 | |
| 15 | app.route("/oauth", auth); |
| 16 | app.route("/subscribe", subscribe); |
| 17 | app.use("/subscribe", cors({ |
| 18 | origin: (origin) => origin, |
| 19 | credentials: true, |
| 20 | })); |
| 21 | app.use("/subscribe/*", cors({ |
| 22 | origin: (origin) => origin, |
| 23 | credentials: true, |
| 24 | })); |
| 25 | |
| 26 | app.get("/api/health", (c) => { |
| 27 | return c.json({ status: "ok" }); |
| 28 | }); |
| 29 | |
| 30 | app.all("*", (c) => { |
| 31 | return c.env.ASSETS.fetch(c.req.raw); |
| 32 | }); |
| 33 | |
| 34 | export default app; |