server as netlify function
This commit is contained in:
29
netlify/edge-functions/index.ts
Normal file
29
netlify/edge-functions/index.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Hono } from "hono";
|
||||
import { cors } from "hono/cors";
|
||||
import { RegisterController } from "@/controllers/register";
|
||||
import { LoginController } from "@/controllers/login";
|
||||
import { handle } from "hono/netlify";
|
||||
|
||||
const app = new Hono().basePath("/api");
|
||||
|
||||
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("/", (c) => {
|
||||
return c.text("Hello Hono!");
|
||||
});
|
||||
|
||||
app.post("/v1/register", RegisterController);
|
||||
|
||||
app.post("/v1/login", LoginController);
|
||||
|
||||
export default handle(app);
|
||||
Reference in New Issue
Block a user