updated to tss adapter in bknd@0.21.0-rc.0

This commit is contained in:
2026-03-15 19:39:13 +05:30
parent 1f342283a0
commit 1925294484
7 changed files with 218 additions and 717 deletions

View File

@@ -1,15 +1,17 @@
// import { getApp as getBkndApp } from "bknd/adapter/nextjs";
import { App } from "bknd";
import config from "../bknd.config";
import { BkndConfig, createFrameworkApp } from "bknd/adapter";
import { getApp as getBkndApp } from "bknd/adapter/tanstack-start";
// --------------------------------- TANSTACK ADAPTER PROTOTYPE -----------------------------------
export async function getApp<Env = NodeJS.ProcessEnv>(
config: BkndConfig<Env>,
args: Env = process.env as Env,
) {
return await createFrameworkApp(config, args);
declare global {
var __bknd: App | undefined
}
const getApp = async () => {
if (!global.__bknd) {
global.__bknd = await getBkndApp(config, process.env);
}
return global.__bknd;
}
// --------------------------------- TANSTACK ADAPTER PROTOTYPE -----------------------------------
export async function getApi({
headers,
@@ -18,9 +20,7 @@ export async function getApi({
verify?: boolean;
headers?: Headers;
}) {
const app = await getApp(config, process.env);
// const app = await getBkndApp(config, process.env);
const app = await getApp();
if (verify) {
const api = app.getApi({ headers });
await api.verifyAuth();

View File

@@ -1,32 +1,9 @@
import { createFileRoute } from "@tanstack/react-router";
import config from "../../bknd.config";
import { createFrameworkApp, type FrameworkBkndConfig } from "bknd/adapter";
// import { getApp } from "bknd/adapter/nextjs";
// const handler = serve({
// ...config,
// });
// --------------------------------- TANSTACK ADAPTER PROTOTYPE -----------------------------------
export async function getApp<Env = NodeJS.ProcessEnv>(
config: FrameworkBkndConfig<Env>,
args: Env = process.env as Env,
) {
return await createFrameworkApp(config, args);
}
function serve(config: FrameworkBkndConfig) {
return async (request: Request) => {
const app = await getApp(config, process.env);
return app.fetch(request);
};
}
import { serve } from "bknd/adapter/tanstack-start";
const handler = serve(config);
// --------------------------------- TANSTACK ADAPTER PROTOTYPE -----------------------------------
export const Route = createFileRoute("/api/$")({
server: {
handlers: {