lets fuckin go
This commit is contained in:
6
packages/server/src/api.ts
Normal file
6
packages/server/src/api.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { Hono } from "hono";
|
||||
|
||||
const api = new Hono().get("/ping", (c) => c.text("pong"));
|
||||
|
||||
export default api;
|
||||
export type ApiType = typeof api;
|
||||
@@ -1,7 +1,15 @@
|
||||
import { Hono } from "hono";
|
||||
import { serveStatic } from "hono/bun";
|
||||
import api from "./api";
|
||||
import { cors } from "hono/cors";
|
||||
|
||||
const app = new Hono();
|
||||
app.use("*", async (c, next) => {
|
||||
console.log(c.req.method, c.req.url);
|
||||
await next();
|
||||
console.log(">>", c.res.status);
|
||||
});
|
||||
|
||||
const isDev = Bun.env.NODE_ENV === "development";
|
||||
const isProd = Bun.env.NODE_ENV === "production";
|
||||
|
||||
@@ -13,4 +21,7 @@ isProd &&
|
||||
})
|
||||
);
|
||||
|
||||
app.use("*", cors());
|
||||
app.route("/api", api);
|
||||
|
||||
export default app;
|
||||
|
||||
Reference in New Issue
Block a user