mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
add: Tanstack Start adapter
This commit is contained in:
1
app/src/adapter/tanstack-start/index.ts
Normal file
1
app/src/adapter/tanstack-start/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./tanstack-start.adapter";
|
||||
@@ -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,
|
||||
});
|
||||
});
|
||||
23
app/src/adapter/tanstack-start/tanstack-start.adapter.ts
Normal file
23
app/src/adapter/tanstack-start/tanstack-start.adapter.ts
Normal 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);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user