mirror of
https://github.com/bknd-io/bknd/
synced 2026-08-04 09:06:01 +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 {
|
export default {
|
||||||
// we can use any libsql config, and if omitted, uses in-memory
|
// we can use any libsql config, and if omitted, uses in-memory
|
||||||
app: (env) => ({
|
|
||||||
connection: {
|
connection: {
|
||||||
url: env?.DB_URL ?? "file:data.db",
|
url: process.env.DB_URL ?? "file:data.db",
|
||||||
},
|
},
|
||||||
}),
|
|
||||||
// an initial config is only applied if the database is empty
|
// an initial config is only applied if the database is empty
|
||||||
initialConfig: {
|
initialConfig: {
|
||||||
data: schema.toJSON(),
|
data: schema.toJSON(),
|
||||||
@@ -33,7 +31,7 @@ export default {
|
|||||||
auth: {
|
auth: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
jwt: {
|
jwt: {
|
||||||
issuer: "bknd-remix-example",
|
issuer: "bknd-waku-example",
|
||||||
secret: secureRandomString(64),
|
secret: secureRandomString(64),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { createFrameworkApp } from "bknd/adapter";
|
import { createFrameworkApp } from "bknd/adapter";
|
||||||
import config from "../../bknd.config";
|
import config from "../bknd.config";
|
||||||
|
|
||||||
export async function getApp() {
|
export async function getApp() {
|
||||||
return await createFrameworkApp(config, process.env, {
|
return await createFrameworkApp(config, process.env, {
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
import { Suspense, lazy } from "react";
|
import { Suspense, lazy } from "react";
|
||||||
import { getUserApi } from "../../lib/waku/server";
|
import { getUserApi } from "../../lib/waku/server";
|
||||||
|
|
||||||
const AdminComponent = lazy(() => import("../../bknd/admin"));
|
const AdminComponent = lazy(() => import("./_components/AdminLoader"));
|
||||||
|
|
||||||
export default async function HomePage() {
|
export default async function HomePage() {
|
||||||
const api = await getUserApi({ verify: true });
|
const api = await getUserApi({ verify: true });
|
||||||
|
|||||||
+2
-2
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
import type { BkndAdminProps } from "bknd/ui";
|
import type { BkndAdminProps } from "bknd/ui";
|
||||||
import { lazy } from "react";
|
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) => {
|
export const AdminLoader = (props: BkndAdminProps) => {
|
||||||
return (
|
return (
|
||||||
@@ -1,16 +1,14 @@
|
|||||||
import { Link } from "waku";
|
import { Link } from "waku";
|
||||||
|
|
||||||
import { Counter } from "../components/counter";
|
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) {
|
async function toggleTodo(todo: any, path: string) {
|
||||||
"use server";
|
"use server";
|
||||||
console.log("toggleTodo", todo, path);
|
|
||||||
const api = await getUserApi();
|
const api = await getUserApi();
|
||||||
await api.data.updateOne("todos", todo.id, {
|
await api.data.updateOne("todos", todo.id, {
|
||||||
done: !todo.done,
|
done: !todo.done,
|
||||||
});
|
});
|
||||||
console.log("rerender");
|
|
||||||
rerender(path);
|
rerender(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"include": ["**/*.ts", "**/*.tsx"],
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"target": "esnext",
|
"target": "esnext",
|
||||||
|
|||||||
Reference in New Issue
Block a user