diff --git a/bun.lockb b/bun.lockb
index f97dc61..ac24c20 100755
Binary files a/bun.lockb and b/bun.lockb differ
diff --git a/examples/bun/index.ts b/examples/bun/index.ts
index 7432622..57c4eae 100644
--- a/examples/bun/index.ts
+++ b/examples/bun/index.ts
@@ -1,10 +1,9 @@
-/*
-// somehow causes types:build issues on app
-
+// @ts-ignore somehow causes types:build issues on app
import type { CreateAppConfig } from "bknd";
+// @ts-ignore somehow causes types:build issues on app
import { serve } from "bknd/adapter/bun";
-const root = "../../node_modules/bknd/dist";
+// this is optional, if omitted, it uses an in-memory database
const config = {
connection: {
type: "libsql",
@@ -16,8 +15,12 @@ const config = {
Bun.serve({
port: 1337,
- fetch: serve(config, root)
+ fetch: serve(
+ config,
+ // this is only required to run inside the same workspace
+ // leave blank if you're running this from a different project
+ "../../node_modules/bknd/dist"
+ )
});
console.log("Server running at http://localhost:1337");
-s*/
diff --git a/examples/bun/tsconfig.json b/examples/bun/tsconfig.json
index 9e6a2e9..6f14404 100644
--- a/examples/bun/tsconfig.json
+++ b/examples/bun/tsconfig.json
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"lib": ["ESNext", "DOM"],
- "target": "ESNext",
+ "target": "ES2022",
"module": "ESNext",
"jsx": "react-jsx",
"allowJs": true,
diff --git a/examples/cloudflare-worker/src/index.ts b/examples/cloudflare-worker/src/index.ts
index e6a9a9c..6a79894 100644
--- a/examples/cloudflare-worker/src/index.ts
+++ b/examples/cloudflare-worker/src/index.ts
@@ -8,15 +8,13 @@ export default serve(
connection: {
type: "libsql",
config: {
- url: env.DB_URL,
- authToken: env.DB_TOKEN
+ url: "http://localhost:8080"
}
}
}),
onBuilt: async (app) => {
- app.modules.server.get("/", (c) => c.json({ hello: "world" }));
- },
- setAdminHtml: true
+ app.modules.server.get("/hello", (c) => c.json({ hello: "world" }));
+ }
},
manifest
);
diff --git a/examples/nextjs/package.json b/examples/nextjs/package.json
index 40b4da3..fc734a4 100644
--- a/examples/nextjs/package.json
+++ b/examples/nextjs/package.json
@@ -4,6 +4,8 @@
"private": true,
"scripts": {
"dev": "next dev",
+ "db": "turso dev --db-file test.db",
+ "db:check": "sqlite3 test.db \"PRAGMA wal_checkpoint(FULL);\"",
"build": "next build",
"start": "next start",
"lint": "next lint"
diff --git a/examples/nextjs/src/pages/api/[...route].ts b/examples/nextjs/src/pages/api/[...route].ts
index a9d64c5..17179a5 100644
--- a/examples/nextjs/src/pages/api/[...route].ts
+++ b/examples/nextjs/src/pages/api/[...route].ts
@@ -9,51 +9,7 @@ export default serve({
connection: {
type: "libsql",
config: {
- url: process.env.DB_URL!,
- authToken: process.env.DB_AUTH_TOKEN!
+ url: "http://localhost:8080"
}
}
-}); /*
-let app: App;
-
-async function getApp() {
- if (!app) {
- app = App.create({
- connection: {
- type: "libsql",
- config: {
- url: process.env.DB_URL!,
- authToken: process.env.DB_AUTH_TOKEN!
- }
- }
- });
- await app.build();
- }
-
- return app;
-}
-
-function getCleanRequest(req: Request) {
- // clean search params from "route" attribute
- const url = new URL(req.url);
- url.searchParams.delete("route");
- return new Request(url.toString(), {
- method: req.method,
- headers: req.headers,
- body: req.body
- });
-}
-
-export default async (req: Request, requestContext: any) => {
- //console.log("here");
- if (!app) {
- app = await getApp();
- }
- //const app = await getApp();
- const request = getCleanRequest(req);
- //console.log("url", req.url);
- //console.log("req", req);
- return app.fetch(request, process.env);
-};
-//export default handle(app.server.getInstance())
-*/
+});
diff --git a/examples/nextjs/test.db b/examples/nextjs/test.db
new file mode 100644
index 0000000..1c856e0
Binary files /dev/null and b/examples/nextjs/test.db differ
diff --git a/examples/node/index.js b/examples/node/index.js
new file mode 100644
index 0000000..92ae1d2
--- /dev/null
+++ b/examples/node/index.js
@@ -0,0 +1,20 @@
+import { serve } from "bknd/adapter/node";
+
+// this is optional, if omitted, it uses an in-memory database
+/** @type {import("bknd").CreateAppConfig} */
+const config = {
+ connection: {
+ type: "libsql",
+ config: {
+ url: "http://localhost:8080"
+ }
+ }
+};
+
+serve(config, {
+ relativeDistPath: "../../node_modules/bknd/dist",
+ port: 1337,
+ listener: ({ port }) => {
+ console.log(`Server is running on http://localhost:${port}`);
+ }
+});
diff --git a/examples/node/package.json b/examples/node/package.json
new file mode 100644
index 0000000..630b647
--- /dev/null
+++ b/examples/node/package.json
@@ -0,0 +1,20 @@
+{
+ "name": "node",
+ "module": "index.js",
+ "type": "module",
+ "private": true,
+ "scripts": {
+ "start": "node index.js",
+ "dev": "tsx --watch index.js"
+ },
+ "dependencies": {
+ "bknd": "workspace:*",
+ "@hono/node-server": "^1.13.3"
+ },
+ "devDependencies": {
+ "tsx": "^4.19.2"
+ },
+ "peerDependencies": {
+ "typescript": "^5.0.0"
+ }
+}
\ No newline at end of file
diff --git a/examples/remix/app/routes/admin.$.tsx b/examples/remix/app/routes/admin.$.tsx
index 76d0c75..d73a208 100644
--- a/examples/remix/app/routes/admin.$.tsx
+++ b/examples/remix/app/routes/admin.$.tsx
@@ -12,7 +12,7 @@ export default function AdminPage() {
return (