mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 12:37:20 +00:00
Merge remote-tracking branch 'origin/main' into fix/with-builder-respect-alias
# Conflicts: # bun.lock
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,
|
||||
});
|
||||
});
|
||||
33
app/src/adapter/tanstack-start/tanstack-start.adapter.ts
Normal file
33
app/src/adapter/tanstack-start/tanstack-start.adapter.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { createFrameworkApp, type FrameworkBkndConfig } from "bknd/adapter";
|
||||
|
||||
export type TanstackStartEnv = NodeJS.ProcessEnv;
|
||||
|
||||
export type TanstackStartConfig<Env = TanstackStartEnv> =
|
||||
FrameworkBkndConfig<Env>;
|
||||
|
||||
/**
|
||||
* Get bknd app instance
|
||||
* @param config - bknd configuration
|
||||
* @param args - environment variables
|
||||
*/
|
||||
export async function getApp<Env = TanstackStartEnv>(
|
||||
config: TanstackStartConfig<Env> = {},
|
||||
args: Env = process.env as Env,
|
||||
) {
|
||||
return await createFrameworkApp(config, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create request handler for src/routes/api.$.ts
|
||||
* @param config - bknd configuration
|
||||
* @param args - environment variables
|
||||
*/
|
||||
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