Add backend framework selection between hono, elysiajs

This commit is contained in:
Aman Varshney
2025-03-26 11:41:41 +05:30
parent b6b113766e
commit 91fe9f861f
40 changed files with 451 additions and 345 deletions

View File

@@ -8,10 +8,8 @@
"compile": "bun build --compile --minify --sourcemap --bytecode ./src/index.ts --outfile server"
},
"dependencies": {
"@hono/trpc-server": "^0.3.4",
"@trpc/server": "^11.0.0",
"dotenv": "^16.4.7",
"hono": "^4.7.5",
"zod": "^3.24.2"
},
"devDependencies": {

View File

@@ -1,33 +0,0 @@
import { trpcServer } from "@hono/trpc-server";
import "dotenv/config";
import { Hono } from "hono";
import { cors } from "hono/cors";
import { logger } from "hono/logger";
import { createContext } from "./lib/context";
import { appRouter } from "./routers/index";
const app = new Hono();
app.use(logger());
app.use(
"/*",
cors({
origin: process.env.CORS_ORIGIN || "",
allowMethods: ["GET", "POST", "OPTIONS"],
}),
);
app.use(
"/trpc/*",
trpcServer({
router: appRouter,
createContext: (_opts, hono) => {
return createContext({ hono });
},
}),
);
app.get("/", (c) => {
return c.text("OK");
});

View File

@@ -1,13 +0,0 @@
import type { Context as HonoContext } from "hono";
export type CreateContextOptions = {
hono: HonoContext;
};
export async function createContext({ hono }: CreateContextOptions) {
return {
session: null,
};
}
export type Context = Awaited<ReturnType<typeof createContext>>;

View File

@@ -8,7 +8,7 @@
"skipLibCheck": true,
"baseUrl": "./",
"outDir": "./dist",
"types": ["node"],
"types": ["node", "bun"],
"jsx": "react-jsx",
"jsxImportSource": "hono/jsx"
},