fix nextjs node adapter import

This commit is contained in:
dswbx
2025-02-06 15:19:25 +01:00
parent 0a5cc2ad98
commit 78d4f928ba
6 changed files with 30 additions and 31 deletions

View File

@@ -139,8 +139,7 @@ describe("json form", () => {
required: ["description"]
};
const lib = new Draft2019(schema);
lib.eachSchema(console.log);
//const lib = new Draft2019(schema);
//lib.eachSchema(console.log);
});
});

View File

@@ -3,7 +3,7 @@
"type": "module",
"sideEffects": false,
"bin": "./dist/cli/index.js",
"version": "0.7.0-rc.5",
"version": "0.7.0-rc.7",
"description": "Lightweight Firebase/Supabase alternative built to run anywhere — incl. Next.js, Remix, Astro, Cloudflare, Bun, Node, AWS Lambda & more.",
"homepage": "https://bknd.io",
"repository": {

View File

@@ -1,7 +1,7 @@
import type { IncomingMessage, ServerResponse } from "node:http";
import { nodeRequestToRequest } from "adapter/utils";
import type { App } from "bknd";
import { type FrameworkBkndConfig, createFrameworkApp } from "bknd/adapter";
import { nodeRequestToRequest } from "bknd/adapter/node";
import { Api } from "bknd/client";
export type NextjsBkndConfig = FrameworkBkndConfig & {

View File

@@ -1,4 +1,3 @@
import type { IncomingMessage } from "node:http";
import { registries } from "bknd";
import {
type LocalAdapterConfig,
@@ -8,30 +7,6 @@ import {
export * from "./node.adapter";
export { StorageLocalAdapter, type LocalAdapterConfig };
export function nodeRequestToRequest(req: IncomingMessage): Request {
let protocol = "http";
try {
protocol = req.headers["x-forwarded-proto"] as string;
} catch (e) {}
const host = req.headers.host;
const url = `${protocol}://${host}${req.url}`;
const headers = new Headers();
for (const [key, value] of Object.entries(req.headers)) {
if (Array.isArray(value)) {
headers.append(key, value.join(", "));
} else if (value) {
headers.append(key, value);
}
}
const method = req.method || "GET";
return new Request(url, {
method,
headers
});
}
export function registerLocalMediaAdapter() {
registries.media.register("local", StorageLocalAdapter);
}

25
app/src/adapter/utils.ts Normal file
View File

@@ -0,0 +1,25 @@
import type { IncomingMessage } from "node:http";
export function nodeRequestToRequest(req: IncomingMessage): Request {
let protocol = "http";
try {
protocol = req.headers["x-forwarded-proto"] as string;
} catch (e) {}
const host = req.headers.host;
const url = `${protocol}://${host}${req.url}`;
const headers = new Headers();
for (const [key, value] of Object.entries(req.headers)) {
if (Array.isArray(value)) {
headers.append(key, value.join(", "));
} else if (value) {
headers.append(key, value);
}
}
const method = req.method || "GET";
return new Request(url, {
method,
headers
});
}

View File

@@ -58,7 +58,7 @@ export function unflatten(
for (const pointer in obj) {
const required = isRequired(pointer, schema);
let subschema = lib.getSchema({ pointer });
console.log("subschema", pointer, subschema, selections);
//console.log("subschema", pointer, subschema, selections);
if (!subschema) {
throw new Error(`"${pointer}" not found in schema`);
}