public commit

This commit is contained in:
dswbx
2024-11-16 12:01:47 +01:00
commit 90f80c4280
582 changed files with 49291 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
import type { LoaderFunctionArgs } from "@remix-run/node";
import { Links, Meta, Outlet, Scripts, ScrollRestoration } from "@remix-run/react";
import { Api } from "bknd";
import { ClientProvider } from "bknd/ui";
export function Layout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<Meta />
<Links />
</head>
<body>
{children}
<ScrollRestoration />
<Scripts />
</body>
</html>
);
}
export const loader = async (args: LoaderFunctionArgs) => {
args.context.api = new Api({
host: new URL(args.request.url).origin
});
return null;
};
export default function App() {
return (
<ClientProvider>
<Outlet />
</ClientProvider>
);
}

View File

@@ -0,0 +1,30 @@
import type { LoaderFunctionArgs, MetaFunction } from "@remix-run/node";
import { useLoaderData } from "@remix-run/react";
import type { Api } from "bknd";
import { useClient } from "bknd/ui";
export const meta: MetaFunction = () => {
return [{ title: "Remix & bknd" }, { name: "description", content: "Welcome to Remix & bknd!" }];
};
export const loader = async (args: LoaderFunctionArgs) => {
const api = args.context.api as Api;
const { data } = await api.data.readMany("todos");
return { data };
};
export default function Index() {
const data = useLoaderData<typeof loader>();
const client = useClient();
const query = client.query().data.entity("todos").readMany();
return (
<div>
hello
<pre>{client.baseUrl}</pre>
<pre>{JSON.stringify(data, null, 2)}</pre>
<pre>{JSON.stringify(query.data, null, 2)}</pre>
</div>
);
}

View File

@@ -0,0 +1,18 @@
import { Suspense, lazy, useEffect, useState } from "react";
const Admin = lazy(() => import("bknd/ui").then((mod) => ({ default: mod.Admin })));
import "bknd/dist/styles.css";
export default function AdminPage() {
const [loaded, setLoaded] = useState(false);
useEffect(() => {
setLoaded(true);
}, []);
if (!loaded) return null;
return (
<Suspense>
<Admin withProvider />
</Suspense>
);
}

View File

@@ -0,0 +1,13 @@
import { serve } from "bknd/adapter/remix";
const handler = serve({
connection: {
type: "libsql",
config: {
url: "http://localhost:8080"
}
}
});
export const loader = handler;
export const action = handler;