-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.ts
41 lines (31 loc) · 1.18 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { Hono } from "hono";
import controller from "./controller";
import { Bindings } from "./type";
const app = new Hono<{ Bindings: Bindings }>();
const middleware = {
root: new Hono<{ Bindings: Bindings }>(),
openai: new Hono<{ Bindings: Bindings }>(),
};
const users = new Hono<{ Bindings: Bindings }>();
const keys = new Hono<{ Bindings: Bindings }>();
const root = new Hono<{ Bindings: Bindings }>();
const openai = new Hono<{ Bindings: Bindings }>();
users.get("/", controller.users.get_all);
users.post("/", controller.users.add);
users.delete("/", controller.users.delete);
users.post("/:id/reset", controller.users.reset);
keys.get("/", controller.keys.get_all);
keys.post("/", controller.keys.add);
keys.delete("/:id", controller.keys.delete);
root.get("/", controller.root.whoami);
openai.post("/*", controller.openai.proxy);
middleware.root.use("*", controller.auth.root);
middleware.openai.use("*", controller.auth.openai);
app.post("/1/users/init", controller.users.init);
app.route("/1", middleware.root);
app.route("/1/users", users);
app.route("/1/keys", keys);
app.route("/1/me", root);
app.route("/v1", middleware.openai);
app.route("/v1", openai);
export default app;