init: me-api 个人简历后台
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+31
@@ -0,0 +1,31 @@
|
||||
import { Hono } from "hono";
|
||||
import { bodyLimit } from "hono/body-limit";
|
||||
import type { HttpBindings } from "@hono/node-server";
|
||||
import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
|
||||
import { appRouter } from "./router";
|
||||
import { createContext } from "./context";
|
||||
import { env } from "./lib/env";
|
||||
|
||||
const app = new Hono<{ Bindings: HttpBindings }>();
|
||||
|
||||
app.use(bodyLimit({ maxSize: 50 * 1024 * 1024 }));
|
||||
app.use("/api/trpc/*", async (c) => {
|
||||
return fetchRequestHandler({
|
||||
endpoint: "/api/trpc",
|
||||
req: c.req.raw,
|
||||
router: appRouter,
|
||||
createContext,
|
||||
});
|
||||
});
|
||||
app.all("/api/*", (c) => c.json({ error: "Not Found" }, 404));
|
||||
|
||||
export default app;
|
||||
|
||||
if (env.isProduction) {
|
||||
const { serve } = await import("@hono/node-server");
|
||||
|
||||
const port = parseInt(process.env.PORT || "3000");
|
||||
serve({ fetch: app.fetch, port }, () => {
|
||||
console.log(`Server running on http://localhost:${port}/`);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user