add: Tanstack Start adapter

This commit is contained in:
2026-02-11 20:29:03 +05:30
parent 224d98879a
commit 384e337bbd
7 changed files with 398 additions and 320 deletions

View File

@@ -0,0 +1 @@
export * from "./tanstack-start.adapter";

View File

@@ -0,0 +1,16 @@
import { afterAll, beforeAll, describe } from "bun:test";
import * as tanstackStart from "./tanstack-start.adapter";
import { disableConsoleLog, enableConsoleLog } from "core/utils";
import { adapterTestSuite } from "adapter/adapter-test-suite";
import { bunTestRunner } from "adapter/bun/test";
import type { TanstackStartConfig } from "./tanstack-start.adapter";
beforeAll(disableConsoleLog);
afterAll(enableConsoleLog);
describe("tanstack start adapter", () => {
adapterTestSuite<TanstackStartConfig>(bunTestRunner, {
makeApp: tanstackStart.getApp,
makeHandler: tanstackStart.serve,
});
});

View File

@@ -0,0 +1,23 @@
import { createFrameworkApp, type FrameworkBkndConfig } from "bknd/adapter";
export type TanstackStartEnv = NodeJS.ProcessEnv;
export type TanstackStartConfig<Env = TanstackStartEnv> =
FrameworkBkndConfig<Env>;
export async function getApp<Env = TanstackStartEnv>(
config: TanstackStartConfig<Env>,
args: Env = process.env as Env,
) {
return await createFrameworkApp(config, args);
}
export function serve<Env = TanstackStartEnv>(
{ ...config }: TanstackStartConfig<Env> = {},
args: Env = process.env as Env,
) {
return async (request: Request) => {
const app = await getApp(config, args);
return app.fetch(request);
};
}