server as netlify function

This commit is contained in:
Matteo Rosati
2026-01-26 15:22:24 +01:00
parent 2d90ce676b
commit a9170932e7
5 changed files with 13 additions and 11846 deletions

3
netlify.toml Normal file
View File

@@ -0,0 +1,3 @@
[[edge_functions]]
function = "index" # The name of your file
path = "/api/*"

View File

@@ -2,8 +2,9 @@ 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();
const app = new Hono().basePath("/api");
app.use(
"/api/v1/*",
@@ -17,17 +18,12 @@ app.use(
}),
);
app.get("/", async (c) => {
return c.json({
message: "ok",
});
app.get("/", (c) => {
return c.text("Hello Hono!");
});
app.post("/api/v1/register", RegisterController);
app.post("/v1/register", RegisterController);
app.post("/api/v1/login", LoginController);
app.post("/v1/login", LoginController);
export default {
port: Bun.env.SERVER_PORT,
fetch: app.fetch,
};
export default handle(app);

11832
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -6,7 +6,7 @@ export const INITIAL_ZOOM = 17;
/**
* MapTiler style URL for the map
*/
export const MAP_STYLE = import.meta.env.VITE_MAPTILER_STYLE;
export const MAP_STYLE = typeof import.meta !== 'undefined' && import.meta.env?.VITE_MAPTILER_STYLE ? import.meta.env.VITE_MAPTILER_STYLE : '';
export const STATUSES = {
SUCCESS: "success",

View File

@@ -20,9 +20,9 @@
"baseUrl": ".",
"paths": {
"@/*": ["./src/*", "./server.ts"],
"@/*": ["./src/*", "netlify/edge-functions/*.ts"],
},
},
"include": ["src/**/*.ts", "src/**/*.tsx", "./server.ts"],
"include": ["src/**/*.ts", "src/**/*.tsx", "netlify/edge-functions/*.ts"],
"exclude": ["node_modules", "dist"],
}