mirror of
https://github.com/bknd-io/bknd/
synced 2026-08-04 09:06:01 +00:00
Refactor web adapter to universal adapter
Rename the web adapter to universal adapter to better reflect its framework-agnostic nature. This change involves updating package.json, file paths, and documentation.
This commit is contained in:
+1
-1
@@ -331,7 +331,7 @@ async function buildAdapters() {
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
tsup.build({
|
tsup.build({
|
||||||
...baseConfig("web"),
|
...baseConfig("universal"),
|
||||||
platform: "neutral",
|
platform: "neutral",
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -233,10 +233,10 @@
|
|||||||
"import": "./dist/adapter/nextjs/index.js",
|
"import": "./dist/adapter/nextjs/index.js",
|
||||||
"require": "./dist/adapter/nextjs/index.js"
|
"require": "./dist/adapter/nextjs/index.js"
|
||||||
},
|
},
|
||||||
"./adapter/web": {
|
"./adapter/universal": {
|
||||||
"types": "./dist/types/adapter/web/index.d.ts",
|
"types": "./dist/types/adapter/universal/index.d.ts",
|
||||||
"import": "./dist/adapter/web/index.js",
|
"import": "./dist/adapter/universal/index.js",
|
||||||
"require": "./dist/adapter/web/index.js"
|
"require": "./dist/adapter/universal/index.js"
|
||||||
},
|
},
|
||||||
"./adapter/nuxt": {
|
"./adapter/nuxt": {
|
||||||
"types": "./dist/types/adapter/nuxt/index.d.ts",
|
"types": "./dist/types/adapter/nuxt/index.d.ts",
|
||||||
@@ -297,7 +297,7 @@
|
|||||||
"adapter/cloudflare": ["./dist/types/adapter/cloudflare/index.d.ts"],
|
"adapter/cloudflare": ["./dist/types/adapter/cloudflare/index.d.ts"],
|
||||||
"adapter/vite": ["./dist/types/adapter/vite/index.d.ts"],
|
"adapter/vite": ["./dist/types/adapter/vite/index.d.ts"],
|
||||||
"adapter/nextjs": ["./dist/types/adapter/nextjs/index.d.ts"],
|
"adapter/nextjs": ["./dist/types/adapter/nextjs/index.d.ts"],
|
||||||
"adapter/web": ["./dist/types/adapter/web/index.d.ts"],
|
"adapter/universal": ["./dist/types/adapter/universal/index.d.ts"],
|
||||||
"adapter/nuxt": ["./dist/types/adapter/nuxt/index.d.ts"],
|
"adapter/nuxt": ["./dist/types/adapter/nuxt/index.d.ts"],
|
||||||
"adapter/react-router": ["./dist/types/adapter/react-router/index.d.ts"],
|
"adapter/react-router": ["./dist/types/adapter/react-router/index.d.ts"],
|
||||||
"adapter/bun": ["./dist/types/adapter/bun/index.d.ts"],
|
"adapter/bun": ["./dist/types/adapter/bun/index.d.ts"],
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from "./universal.adapter";
|
||||||
+3
-3
@@ -1,5 +1,5 @@
|
|||||||
import { afterAll, beforeAll, describe, test, expect } from "bun:test";
|
import { afterAll, beforeAll, describe, test, expect } from "bun:test";
|
||||||
import { createBknd } from "./web.adapter";
|
import { createBknd } from "./universal.adapter";
|
||||||
import { disableConsoleLog, enableConsoleLog } from "core/utils";
|
import { disableConsoleLog, enableConsoleLog } from "core/utils";
|
||||||
import { adapterTestSuite } from "adapter/adapter-test-suite";
|
import { adapterTestSuite } from "adapter/adapter-test-suite";
|
||||||
import { bunTestRunner } from "adapter/bun/test";
|
import { bunTestRunner } from "adapter/bun/test";
|
||||||
@@ -7,7 +7,7 @@ import { bunTestRunner } from "adapter/bun/test";
|
|||||||
beforeAll(disableConsoleLog);
|
beforeAll(disableConsoleLog);
|
||||||
afterAll(enableConsoleLog);
|
afterAll(enableConsoleLog);
|
||||||
|
|
||||||
describe("web adapter via createBknd", () => {
|
describe("universal adapter via createBknd", () => {
|
||||||
adapterTestSuite(bunTestRunner, {
|
adapterTestSuite(bunTestRunner, {
|
||||||
makeApp: (options, args) => createBknd({ mode: "api", options }, args).getApp(),
|
makeApp: (options, args) => createBknd({ mode: "api", options }, args).getApp(),
|
||||||
makeHandler: (options, args) => createBknd({ mode: "api", options: options ?? {} }, args).serve(),
|
makeHandler: (options, args) => createBknd({ mode: "api", options: options ?? {} }, args).serve(),
|
||||||
@@ -44,7 +44,7 @@ describe("web adapter via createBknd", () => {
|
|||||||
|
|
||||||
|
|
||||||
// ------------------------ MODE STANDALONE ------------------------
|
// ------------------------ MODE STANDALONE ------------------------
|
||||||
describe("web adapter via createBknd in standalone mode", () => {
|
describe("universal adapter via createBknd in standalone mode", () => {
|
||||||
adapterTestSuite(bunTestRunner, {
|
adapterTestSuite(bunTestRunner, {
|
||||||
makeApp: (options, args) => createBknd({ mode: "standalone", options }, args).getApp(),
|
makeApp: (options, args) => createBknd({ mode: "standalone", options }, args).getApp(),
|
||||||
makeHandler: (options, args) => createBknd({ mode: "standalone", options: options ?? {} }, args).serve(),
|
makeHandler: (options, args) => createBknd({ mode: "standalone", options: options ?? {} }, args).serve(),
|
||||||
@@ -1 +0,0 @@
|
|||||||
export * from "./web.adapter";
|
|
||||||
@@ -1,12 +1,3 @@
|
|||||||
{
|
{
|
||||||
"pages": [
|
"pages": ["nextjs", "react-router", "astro", "sveltekit", "tanstack-start", "universal", "vite", "nuxt"]
|
||||||
"nextjs",
|
|
||||||
"react-router",
|
|
||||||
"astro",
|
|
||||||
"sveltekit",
|
|
||||||
"tanstack-start",
|
|
||||||
"web",
|
|
||||||
"vite",
|
|
||||||
"nuxt"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-9
@@ -1,14 +1,14 @@
|
|||||||
---
|
---
|
||||||
title: "Web Adapter"
|
title: "Universal Adapter"
|
||||||
description: "Bring bknd to any web framework or runtime"
|
description: "Bring bknd to any web framework or runtime"
|
||||||
tags: ["documentation"]
|
tags: ["documentation"]
|
||||||
---
|
---
|
||||||
|
|
||||||
## What is the Web Adapter?
|
## What is the Universal Adapter?
|
||||||
|
|
||||||
The web adapter (`bknd/adapter/web`) is a framework/runtime agnostic adapter which can integrate `bknd` into **any** web framework or runtime — even ones without a dedicated adapter.
|
The universal adapter (`bknd/adapter/universal`) is a framework/runtime agnostic adapter which can integrate `bknd` into **any** web framework or runtime — even ones without a dedicated adapter.
|
||||||
|
|
||||||
**Use the web adapter when:**
|
**Use the universal adapter when:**
|
||||||
- Your framework doesn't have a dedicated bknd adapter
|
- Your framework doesn't have a dedicated bknd adapter
|
||||||
- You want full control over your server setup
|
- You want full control over your server setup
|
||||||
- You're building a custom server or edge function
|
- You're building a custom server or edge function
|
||||||
@@ -44,7 +44,7 @@ bun add bknd
|
|||||||
Start by creating a config file:
|
Start by creating a config file:
|
||||||
|
|
||||||
```typescript title="bknd.config.ts"
|
```typescript title="bknd.config.ts"
|
||||||
import type { Config } from "bknd/adapter/web";
|
import type { Config } from "bknd/adapter/universal";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
connection: {
|
connection: {
|
||||||
@@ -60,7 +60,7 @@ Use `Config<"api">` when you are using a React-based framework otherwise use `Co
|
|||||||
|
|
||||||
### Helper Singleton
|
### Helper Singleton
|
||||||
```typescript title="lib/bknd.ts"
|
```typescript title="lib/bknd.ts"
|
||||||
import { createBknd } from "bknd/adapter/web";
|
import { createBknd } from "bknd/adapter/universal";
|
||||||
import config from "../bknd.config";
|
import config from "../bknd.config";
|
||||||
|
|
||||||
export const bknd = createBknd({ mode: "standalone", options: config }, process.env);
|
export const bknd = createBknd({ mode: "standalone", options: config }, process.env);
|
||||||
@@ -112,7 +112,7 @@ No server-side admin configuration needed. The admin UI runs entirely in the bro
|
|||||||
For non-React frameworks or standalone servers, enable the admin controller:
|
For non-React frameworks or standalone servers, enable the admin controller:
|
||||||
|
|
||||||
```typescript title="src/bknd.ts"
|
```typescript title="src/bknd.ts"
|
||||||
import { createBknd } from "bknd/adapter/web";
|
import { createBknd } from "bknd/adapter/universal";
|
||||||
import config from "../bknd.config";
|
import config from "../bknd.config";
|
||||||
|
|
||||||
export const bknd = createBknd({ mode: "standalone", options: config }, env);
|
export const bknd = createBknd({ mode: "standalone", options: config }, env);
|
||||||
@@ -128,7 +128,7 @@ You'll also need to serve the admin's static assets (JS, CSS). Choose one of thr
|
|||||||
Use Hono's platform-specific `serveStatic` in `bknd.config.ts` to serve assets from `node_modules/bknd/dist/static/`:
|
Use Hono's platform-specific `serveStatic` in `bknd.config.ts` to serve assets from `node_modules/bknd/dist/static/`:
|
||||||
|
|
||||||
```typescript title="bknd.config.ts"
|
```typescript title="bknd.config.ts"
|
||||||
import type { Config } from "bknd/adapter/web";
|
import type { Config } from "bknd/adapter/universal";
|
||||||
import { serveStatic } from "hono/bun"; // or "@hono/node-server/serve-static"
|
import { serveStatic } from "hono/bun"; // or "@hono/node-server/serve-static"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -173,7 +173,7 @@ Per-framework output paths:
|
|||||||
For environments without filesystem access:
|
For environments without filesystem access:
|
||||||
|
|
||||||
```typescript title="bknd.config.ts"
|
```typescript title="bknd.config.ts"
|
||||||
import type { Config } from "bknd/adapter/web";
|
import type { Config } from "bknd/adapter/universal";
|
||||||
import { serveStaticViaImport } from "bknd/adapter";
|
import { serveStaticViaImport } from "bknd/adapter";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -47,8 +47,8 @@ bknd seamlessly integrates with popular frameworks, allowing you to use what you
|
|||||||
|
|
||||||
<Card
|
<Card
|
||||||
icon={<Icon icon="tabler:world" className="text-fd-primary !size-6" />}
|
icon={<Icon icon="tabler:world" className="text-fd-primary !size-6" />}
|
||||||
title="Web Adapter"
|
title="Universal Web Adapter"
|
||||||
href="/integration/web"
|
href="/integration/universal"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Card title="Yours missing?" href="https://github.com/bknd-io/bknd/issues/new">
|
<Card title="Yours missing?" href="https://github.com/bknd-io/bknd/issues/new">
|
||||||
|
|||||||
@@ -170,8 +170,8 @@ Pick your framework or runtime to get started.
|
|||||||
|
|
||||||
<Card
|
<Card
|
||||||
icon={<Icon icon="tabler:world" className="text-fd-primary !size-6" />}
|
icon={<Icon icon="tabler:world" className="text-fd-primary !size-6" />}
|
||||||
title="Web Adapter"
|
title="Universal Web Adapter"
|
||||||
href="/integration/web"
|
href="/integration/universal"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Card
|
<Card
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { em, entity, text, boolean } from "bknd";
|
import { em, entity, text, boolean } from "bknd";
|
||||||
import { registerLocalMediaAdapter } from "bknd/adapter/node";
|
import { registerLocalMediaAdapter } from "bknd/adapter/node";
|
||||||
import type { Config } from "bknd/adapter/web";
|
import type { Config } from "bknd/adapter/universal";
|
||||||
|
|
||||||
const local = registerLocalMediaAdapter();
|
const local = registerLocalMediaAdapter();
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { createBknd } from "bknd/adapter/web";
|
import { createBknd } from "bknd/adapter/universal";
|
||||||
import bkndConfig from "../../bknd.config";
|
import bkndConfig from "../../bknd.config";
|
||||||
import type { EnvGetter } from "@builder.io/qwik-city/middleware/request-handler";
|
import type { EnvGetter } from "@builder.io/qwik-city/middleware/request-handler";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user