added fallback route to server, created extensive setup instructions in docs

This commit is contained in:
dswbx
2024-12-24 16:01:42 +01:00
parent 8ef11aa382
commit 06125f1afe
20 changed files with 564 additions and 174 deletions

View File

@@ -1,11 +1,11 @@
// @ts-ignore somehow causes types:build issues on app
import { type BunAdapterOptions, serve } from "bknd/adapter/bun";
import { type BunBkndConfig, serve } from "bknd/adapter/bun";
// Actually, all it takes is the following line:
// serve();
// this is optional, if omitted, it uses an in-memory database
const config: BunAdapterOptions = {
const config: BunBkndConfig = {
connection: {
type: "libsql",
config: {

6
examples/bun/minimal.ts Normal file
View File

@@ -0,0 +1,6 @@
import { createApp } from "bknd";
const app = createApp();
await app.build();
export default app;

View File

@@ -1,4 +1,4 @@
import type { InferGetServerSidePropsType } from "next";
import type { InferGetServerSidePropsType as InferProps } from "next";
import dynamic from "next/dynamic";
import { withApi } from "bknd/adapter/nextjs";
@@ -16,9 +16,7 @@ export const getServerSideProps = withApi(async (context) => {
};
});
export default function AdminPage({
user
}: InferGetServerSidePropsType<typeof getServerSideProps>) {
export default function AdminPage({ user }: InferProps<typeof getServerSideProps>) {
if (typeof document === "undefined") return null;
return (
<Admin withProvider={{ user }} config={{ basepath: "/admin", logo_return_path: "/../" }} />

View File

@@ -1,25 +1,22 @@
// pages/admin/[[...admin]].tsx
import { withApi } from "bknd/adapter/nextjs";
// pages/admin/[[...admin]].tsx
import type { InferGetServerSidePropsType as InferProps } from "next";
import dynamic from "next/dynamic";
import "bknd/dist/styles.css";
/*export const config = {
runtime: "experimental-edge"
}*/
const Admin = dynamic(() => import("bknd/ui").then((mod) => mod.Admin), {
ssr: false,
ssr: false
});
export const getServerSideProps = withApi(async (context) => {
return {
props: {
user: context.api.getUser(),
},
user: context.api.getUser()
}
};
});
export default function AdminPage() {
export default function AdminPage({ user }: InferProps<typeof getServerSideProps>) {
if (typeof document === "undefined") return null;
return <Admin withProvider config={{ basepath: "/admin" }} />;
return <Admin withProvider={{ user }} config={{ basepath: "/admin" }} />;
}