mirror of
https://github.com/bknd-io/bknd/
synced 2026-08-02 08:06:00 +00:00
finalize waku example
This commit is contained in:
Vendored
-15
@@ -1,15 +0,0 @@
|
||||
import type { DB } from "bknd/core";
|
||||
import type { Insertable, Selectable, Updateable, Generated } from "kysely";
|
||||
|
||||
declare global {
|
||||
type BkndEntity<T extends keyof DB> = Selectable<DB[T]>;
|
||||
type BkndEntityCreate<T extends keyof DB> = Insertable<DB[T]>;
|
||||
type BkndEntityUpdate<T extends keyof DB> = Updateable<DB[T]>;
|
||||
}
|
||||
|
||||
interface Database {
|
||||
}
|
||||
|
||||
declare module "bknd/core" {
|
||||
interface DB extends Database {}
|
||||
}
|
||||
@@ -21,11 +21,9 @@ declare module "bknd/core" {
|
||||
|
||||
export default {
|
||||
// we can use any libsql config, and if omitted, uses in-memory
|
||||
app: (env) => ({
|
||||
connection: {
|
||||
url: env?.DB_URL ?? "file:data.db",
|
||||
},
|
||||
}),
|
||||
connection: {
|
||||
url: process.env.DB_URL ?? "file:data.db",
|
||||
},
|
||||
// an initial config is only applied if the database is empty
|
||||
initialConfig: {
|
||||
data: schema.toJSON(),
|
||||
@@ -33,7 +31,7 @@ export default {
|
||||
auth: {
|
||||
enabled: true,
|
||||
jwt: {
|
||||
issuer: "bknd-remix-example",
|
||||
issuer: "bknd-waku-example",
|
||||
secret: secureRandomString(64),
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createFrameworkApp } from "bknd/adapter";
|
||||
import config from "../../bknd.config";
|
||||
import config from "../bknd.config";
|
||||
|
||||
export async function getApp() {
|
||||
return await createFrameworkApp(config, process.env, {
|
||||
@@ -5,7 +5,7 @@
|
||||
import { Suspense, lazy } from "react";
|
||||
import { getUserApi } from "../../lib/waku/server";
|
||||
|
||||
const AdminComponent = lazy(() => import("../../bknd/admin"));
|
||||
const AdminComponent = lazy(() => import("./_components/AdminLoader"));
|
||||
|
||||
export default async function HomePage() {
|
||||
const api = await getUserApi({ verify: true });
|
||||
|
||||
+2
-2
@@ -2,9 +2,9 @@
|
||||
|
||||
import type { BkndAdminProps } from "bknd/ui";
|
||||
import { lazy } from "react";
|
||||
import { BrowserOnly } from "../../lib/waku/client";
|
||||
import { BrowserOnly } from "../../../lib/waku/client";
|
||||
|
||||
const AdminImpl = import.meta.env.SSR ? undefined : lazy(() => import("./impl"));
|
||||
const AdminImpl = import.meta.env.SSR ? undefined : lazy(() => import("./AdminImpl"));
|
||||
|
||||
export const AdminLoader = (props: BkndAdminProps) => {
|
||||
return (
|
||||
@@ -1,16 +1,14 @@
|
||||
import { Link } from "waku";
|
||||
|
||||
import { Counter } from "../components/counter";
|
||||
import { getUserApi, rerender } from "../lib/waku/server";
|
||||
import { rerender, getUserApi } from "../lib/waku/server";
|
||||
|
||||
async function toggleTodo(todo: any, path: string) {
|
||||
"use server";
|
||||
console.log("toggleTodo", todo, path);
|
||||
const api = await getUserApi();
|
||||
await api.data.updateOne("todos", todo.id, {
|
||||
done: !todo.done,
|
||||
});
|
||||
console.log("rerender");
|
||||
rerender(path);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"include": ["**/*.ts", "**/*.tsx"],
|
||||
"compilerOptions": {
|
||||
"strict": true,
|
||||
"target": "esnext",
|
||||
|
||||
Reference in New Issue
Block a user