mirror of
https://github.com/bknd-io/bknd/
synced 2026-08-03 16:46:00 +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({
|
||||
...baseConfig("web"),
|
||||
...baseConfig("universal"),
|
||||
platform: "neutral",
|
||||
}),
|
||||
|
||||
|
||||
+5
-5
@@ -233,10 +233,10 @@
|
||||
"import": "./dist/adapter/nextjs/index.js",
|
||||
"require": "./dist/adapter/nextjs/index.js"
|
||||
},
|
||||
"./adapter/web": {
|
||||
"types": "./dist/types/adapter/web/index.d.ts",
|
||||
"import": "./dist/adapter/web/index.js",
|
||||
"require": "./dist/adapter/web/index.js"
|
||||
"./adapter/universal": {
|
||||
"types": "./dist/types/adapter/universal/index.d.ts",
|
||||
"import": "./dist/adapter/universal/index.js",
|
||||
"require": "./dist/adapter/universal/index.js"
|
||||
},
|
||||
"./adapter/nuxt": {
|
||||
"types": "./dist/types/adapter/nuxt/index.d.ts",
|
||||
@@ -297,7 +297,7 @@
|
||||
"adapter/cloudflare": ["./dist/types/adapter/cloudflare/index.d.ts"],
|
||||
"adapter/vite": ["./dist/types/adapter/vite/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/react-router": ["./dist/types/adapter/react-router/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 { createBknd } from "./web.adapter";
|
||||
import { createBknd } from "./universal.adapter";
|
||||
import { disableConsoleLog, enableConsoleLog } from "core/utils";
|
||||
import { adapterTestSuite } from "adapter/adapter-test-suite";
|
||||
import { bunTestRunner } from "adapter/bun/test";
|
||||
@@ -7,7 +7,7 @@ import { bunTestRunner } from "adapter/bun/test";
|
||||
beforeAll(disableConsoleLog);
|
||||
afterAll(enableConsoleLog);
|
||||
|
||||
describe("web adapter via createBknd", () => {
|
||||
describe("universal adapter via createBknd", () => {
|
||||
adapterTestSuite(bunTestRunner, {
|
||||
makeApp: (options, args) => createBknd({ mode: "api", options }, args).getApp(),
|
||||
makeHandler: (options, args) => createBknd({ mode: "api", options: options ?? {} }, args).serve(),
|
||||
@@ -44,7 +44,7 @@ describe("web adapter via createBknd", () => {
|
||||
|
||||
|
||||
// ------------------------ MODE STANDALONE ------------------------
|
||||
describe("web adapter via createBknd in standalone mode", () => {
|
||||
describe("universal adapter via createBknd in standalone mode", () => {
|
||||
adapterTestSuite(bunTestRunner, {
|
||||
makeApp: (options, args) => createBknd({ mode: "standalone", options }, args).getApp(),
|
||||
makeHandler: (options, args) => createBknd({ mode: "standalone", options: options ?? {} }, args).serve(),
|
||||
@@ -1 +0,0 @@
|
||||
export * from "./web.adapter";
|
||||
@@ -1,12 +1,3 @@
|
||||
{
|
||||
"pages": [
|
||||
"nextjs",
|
||||
"react-router",
|
||||
"astro",
|
||||
"sveltekit",
|
||||
"tanstack-start",
|
||||
"web",
|
||||
"vite",
|
||||
"nuxt"
|
||||
]
|
||||
"pages": ["nextjs", "react-router", "astro", "sveltekit", "tanstack-start", "universal", "vite", "nuxt"]
|
||||
}
|
||||
|
||||
+10
-10
@@ -1,14 +1,14 @@
|
||||
---
|
||||
title: "Web Adapter"
|
||||
title: "Universal Adapter"
|
||||
description: "Bring bknd to any web framework or runtime"
|
||||
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
|
||||
- You want full control over your server setup
|
||||
- You're building a custom server or edge function
|
||||
@@ -44,7 +44,7 @@ bun add bknd
|
||||
Start by creating a config file:
|
||||
|
||||
```typescript title="bknd.config.ts"
|
||||
import type { Config } from "bknd/adapter/web";
|
||||
import type { Config } from "bknd/adapter/universal";
|
||||
|
||||
export default {
|
||||
connection: {
|
||||
@@ -60,7 +60,7 @@ Use `Config<"api">` when you are using a React-based framework otherwise use `Co
|
||||
|
||||
### Helper Singleton
|
||||
```typescript title="lib/bknd.ts"
|
||||
import { createBknd } from "bknd/adapter/web";
|
||||
import { createBknd } from "bknd/adapter/universal";
|
||||
import config from "../bknd.config";
|
||||
|
||||
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:
|
||||
|
||||
```typescript title="src/bknd.ts"
|
||||
import { createBknd } from "bknd/adapter/web";
|
||||
import { createBknd } from "bknd/adapter/universal";
|
||||
import config from "../bknd.config";
|
||||
|
||||
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/`:
|
||||
|
||||
```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"
|
||||
|
||||
export default {
|
||||
@@ -173,7 +173,7 @@ Per-framework output paths:
|
||||
For environments without filesystem access:
|
||||
|
||||
```typescript title="bknd.config.ts"
|
||||
import type { Config } from "bknd/adapter/web";
|
||||
import type { Config } from "bknd/adapter/universal";
|
||||
import { serveStaticViaImport } from "bknd/adapter";
|
||||
|
||||
export default {
|
||||
@@ -274,4 +274,4 @@ export type Config<T extends AdapterModeWithOptions["mode"]> = Extract<
|
||||
Parameters<typeof createBknd>[0],
|
||||
{ mode: T }
|
||||
>['options'];
|
||||
```
|
||||
```
|
||||
@@ -45,10 +45,10 @@ bknd seamlessly integrates with popular frameworks, allowing you to use what you
|
||||
href="/integration/nuxt"
|
||||
/>
|
||||
|
||||
<Card
|
||||
icon={<Icon icon="tabler:world" className="text-fd-primary !size-6" />}
|
||||
title="Web Adapter"
|
||||
href="/integration/web"
|
||||
<Card
|
||||
icon={<Icon icon="tabler:world" className="text-fd-primary !size-6" />}
|
||||
title="Universal Web Adapter"
|
||||
href="/integration/universal"
|
||||
/>
|
||||
|
||||
<Card title="Yours missing?" href="https://github.com/bknd-io/bknd/issues/new">
|
||||
|
||||
@@ -168,10 +168,10 @@ Pick your framework or runtime to get started.
|
||||
href="/integration/aws"
|
||||
/>
|
||||
|
||||
<Card
|
||||
icon={<Icon icon="tabler:world" className="text-fd-primary !size-6" />}
|
||||
title="Web Adapter"
|
||||
href="/integration/web"
|
||||
<Card
|
||||
icon={<Icon icon="tabler:world" className="text-fd-primary !size-6" />}
|
||||
title="Universal Web Adapter"
|
||||
href="/integration/universal"
|
||||
/>
|
||||
|
||||
<Card
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { em, entity, text, boolean } from "bknd";
|
||||
import { registerLocalMediaAdapter } from "bknd/adapter/node";
|
||||
import type { Config } from "bknd/adapter/web";
|
||||
import type { Config } from "bknd/adapter/universal";
|
||||
|
||||
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 type { EnvGetter } from "@builder.io/qwik-city/middleware/request-handler";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user