unified runtime and framework adapters

This commit is contained in:
dswbx
2024-12-24 09:43:16 +01:00
parent c1e92e503b
commit 76da14294c
20 changed files with 276 additions and 253 deletions

View File

@@ -1,4 +1,4 @@
import { Api, App } from "bknd";
import { App } from "bknd";
import { serve } from "bknd/adapter/astro";
import { registerLocalMediaAdapter } from "bknd/adapter/node";
import { boolean, em, entity, text } from "bknd/data";

View File

@@ -2,19 +2,17 @@ import { serve } from "bknd/adapter/cloudflare";
import manifest from "__STATIC_CONTENT_MANIFEST";
export default serve(
{
app: (env: Env) => ({
connection: {
type: "libsql",
config: {
url: "http://localhost:8080"
}
export default serve({
app: (env: Env) => ({
connection: {
type: "libsql",
config: {
url: "http://localhost:8080"
}
}),
onBuilt: async (app) => {
app.modules.server.get("/hello", (c) => c.json({ hello: "world" }));
}
}),
onBuilt: async (app) => {
app.modules.server.get("/custom", (c) => c.json({ hello: "world" }));
},
manifest
);
});

View File

@@ -4,7 +4,7 @@ import { serve } from "bknd/adapter/node";
// serve();
// this is optional, if omitted, it uses an in-memory database
/** @type {import("bknd/adapter/node").NodeAdapterOptions} */
/** @type {import("bknd/adapter/node").NodeBkndConfig} */
const config = {
connection: {
type: "libsql",
@@ -14,7 +14,7 @@ const config = {
},
// this is only required to run inside the same workspace
// leave blank if you're running this from a different project
relativeDistPath: "../../app/dist"
distPath: "../../app/dist"
};
serve(config);