docs/src/index.ts 720 B raw
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.use(
16
	"/subscribe",
17
	cors({
18
		origin: (origin) => origin,
19
		credentials: true,
20
	}),
21
);
22
app.use(
23
	"/subscribe/*",
24
	cors({
25
		origin: (origin) => origin,
26
		credentials: true,
27
	}),
28
);
29
30
app.route("/oauth", auth);
31
app.route("/subscribe", subscribe);
32
33
app.get("/api/health", (c) => {
34
	return c.json({ status: "ok" });
35
});
36
37
app.all("*", (c) => {
38
	return c.env.ASSETS.fetch(c.req.raw);
39
});
40
41
export default app;