54 lines
1.1 KiB
TypeScript
54 lines
1.1 KiB
TypeScript
import { Hono } from "hono";
|
|
import { cors } from "hono/cors";
|
|
// import { upgradeWebSocket, websocket } from "hono/bun";
|
|
import { RegisterController } from "@/controllers/register";
|
|
import { LoginController } from "@/controllers/login";
|
|
|
|
const app = new Hono();
|
|
|
|
app.use(
|
|
"/api/v1/*",
|
|
cors({
|
|
origin: "*",
|
|
allowHeaders: ["X-Custom-Header", "Upgrade-Insecure-Requests"],
|
|
allowMethods: ["POST", "GET", "OPTIONS"],
|
|
exposeHeaders: ["Content-Length", "X-Kuma-Revision"],
|
|
maxAge: 600,
|
|
credentials: true,
|
|
}),
|
|
);
|
|
|
|
app.get("/", async (c) => {
|
|
return c.json({
|
|
message: "ok",
|
|
});
|
|
});
|
|
|
|
app.post("/api/v1/register", RegisterController);
|
|
|
|
app.post("/api/v1/login", LoginController);
|
|
|
|
// app.get(
|
|
// "/ws",
|
|
// upgradeWebSocket((c) => {
|
|
// return {
|
|
// onOpen(e, ws) {
|
|
// console.log("Server: Connection opened");
|
|
// ws.send("Hello!");
|
|
// },
|
|
// onClose: () => {
|
|
// console.log("Server: Connection closed");
|
|
// },
|
|
// onMessage: (ev) => {
|
|
// console.log(ev.data);
|
|
// },
|
|
// };
|
|
// }),
|
|
// );
|
|
|
|
export default {
|
|
port: Bun.env.SERVER_PORT,
|
|
fetch: app.fetch,
|
|
// websocket,
|
|
};
|