minor fixes for nextjs

This commit is contained in:
dswbx
2025-03-03 07:10:32 +01:00
parent 09074f6591
commit 00f52eb096
6 changed files with 19 additions and 5 deletions

View File

@@ -68,7 +68,7 @@ export async function replacePackageJsonVersions(
export async function updateBkndPackages(dir?: string, map?: Record<string, string>) { export async function updateBkndPackages(dir?: string, map?: Record<string, string>) {
const versions = { const versions = {
bknd: "^" + (await sysGetVersion()), bknd: await sysGetVersion(),
...(map ?? {}), ...(map ?? {}),
}; };
await replacePackageJsonVersions( await replacePackageJsonVersions(

View File

@@ -264,7 +264,6 @@ export class FetchPromise<T = ApiResponse<any>> implements Promise<T> {
} else { } else {
resBody = res.body; resBody = res.body;
} }
console.groupEnd();
return createResponseProxy<T>(res, resBody, resData); return createResponseProxy<T>(res, resBody, resData);
} }

View File

@@ -286,7 +286,7 @@ export class ModuleManager {
return result as unknown as ConfigTable; return result as unknown as ConfigTable;
}, },
this.verbosity > Verbosity.silent ? [] : ["log", "error", "warn"], this.verbosity > Verbosity.silent ? [] : ["error"],
); );
this.logger this.logger

View File

@@ -1,5 +1,9 @@
import { getApp } from "@/bknd"; import { getApp } from "@/bknd";
// if you're not using a local media adapter, or file database,
// you can uncomment this line to enable running bknd on edge
// export const runtime = "edge";
const handler = async (request: Request) => { const handler = async (request: Request) => {
const app = await getApp(); const app = await getApp();
return app.fetch(request); return app.fetch(request);

3
examples/nextjs/src/app/env/route.ts vendored Normal file
View File

@@ -0,0 +1,3 @@
export const GET = async (req: Request) => {
return Response.json(process.env);
};

View File

@@ -2,12 +2,20 @@ import { type NextjsBkndConfig, getApp as getBkndApp } from "bknd/adapter/nextjs
import { registerLocalMediaAdapter } from "bknd/adapter/node"; import { registerLocalMediaAdapter } from "bknd/adapter/node";
import { headers } from "next/headers"; import { headers } from "next/headers";
// The local media adapter works well in development, and server based
// deployments. However, on vercel or any other serverless deployments,
// you shouldn't use a filesystem based media adapter.
//
// Additionally, if you run the bknd api on the "edge" runtime,
// this would not work as well.
//
// For production, it is recommended to uncomment the line below.
registerLocalMediaAdapter(); registerLocalMediaAdapter();
export const config = { export const config = {
connection: { connection: {
// make sure to use a remote URL for production! url: process.env.DB_URL as string,
url: "file:data.db", authToken: process.env.DB_TOKEN as string,
}, },
} as const satisfies NextjsBkndConfig; } as const satisfies NextjsBkndConfig;