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

5
examples/remix/.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
node_modules
/.cache
/build
.env

1
examples/remix/README.md Normal file
View File

@@ -0,0 +1 @@
# Remix & bknd

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;

View File

@@ -0,0 +1,33 @@
{
"name": "remix",
"private": true,
"sideEffects": false,
"type": "module",
"scripts": {
"build": "remix vite:build",
"dev": "remix vite:dev",
"lint": "eslint --ignore-path .gitignore --cache --cache-location ./node_modules/.cache/eslint .",
"start": "remix-serve ./build/server/index.js",
"typecheck": "tsc"
},
"dependencies": {
"@remix-run/node": "^2.14.0",
"@remix-run/react": "^2.14.0",
"@remix-run/serve": "^2.14.0",
"bknd": "workspace:*",
"isbot": "^4.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@remix-run/dev": "^2.14.0",
"@types/react": "^18.2.20",
"@types/react-dom": "^18.2.7",
"typescript": "^5.1.6",
"vite": "^5.1.0",
"vite-tsconfig-paths": "^4.2.1"
},
"engines": {
"node": ">=20.0.0"
}
}

View File

View File

@@ -0,0 +1,30 @@
{
"include": [
"**/*.ts",
"**/*.tsx",
"**/.server/**/*.ts",
"**/.server/**/*.tsx",
"**/.client/**/*.ts",
"**/.client/**/*.tsx"
],
"compilerOptions": {
"lib": ["DOM", "DOM.Iterable", "ES2022"],
"types": ["@remix-run/node", "vite/client"],
"isolatedModules": true,
"esModuleInterop": true,
"jsx": "react-jsx",
"module": "ESNext",
"moduleResolution": "Bundler",
"resolveJsonModule": true,
"target": "ES2022",
"strict": true,
"allowJs": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"baseUrl": ".",
"paths": {
"~/*": ["./app/*"]
},
"noEmit": true
}
}

View File

@@ -0,0 +1,24 @@
import { vitePlugin as remix } from "@remix-run/dev";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
declare module "@remix-run/node" {
interface Future {
v3_singleFetch: true;
}
}
export default defineConfig({
plugins: [
remix({
future: {
v3_fetcherPersist: true,
v3_relativeSplatPath: true,
v3_throwAbortReason: true,
v3_singleFetch: true,
v3_lazyRouteDiscovery: true,
},
}),
tsconfigPaths(),
],
});