replaced remix with react-router

This commit is contained in:
dswbx
2025-03-14 15:32:43 +01:00
parent b3a0ecbe6d
commit b763826754
49 changed files with 562 additions and 488 deletions

View File

@@ -0,0 +1 @@
export * from "./react-router.adapter";

View File

@@ -1,18 +1,17 @@
import type { App } from "bknd";
import { type FrameworkBkndConfig, createFrameworkApp } from "bknd/adapter";
export type RemixBkndConfig<Args = RemixContext> = FrameworkBkndConfig<Args>;
type RemixContext = {
type ReactRouterContext = {
request: Request;
};
export type ReactRouterBkndConfig<Args = ReactRouterContext> = FrameworkBkndConfig<Args>;
let app: App;
let building: boolean = false;
export async function getApp<Args extends RemixContext = RemixContext>(
config: RemixBkndConfig<Args>,
args?: Args
export async function getApp<Args extends ReactRouterContext = ReactRouterContext>(
config: ReactRouterBkndConfig<Args>,
args?: Args,
) {
if (building) {
while (building) {
@@ -30,8 +29,8 @@ export async function getApp<Args extends RemixContext = RemixContext>(
return app;
}
export function serve<Args extends RemixContext = RemixContext>(
config: RemixBkndConfig<Args> = {},
export function serve<Args extends ReactRouterContext = ReactRouterContext>(
config: ReactRouterBkndConfig<Args> = {},
) {
return async (args: Args) => {
app = await getApp(config, args);

View File

@@ -1,22 +0,0 @@
import { useAuth } from "bknd/client";
import type { BkndAdminProps } from "bknd/ui";
import { Suspense, lazy, useEffect, useState } from "react";
export function adminPage(props?: BkndAdminProps) {
const Admin = lazy(() => import("bknd/ui").then((mod) => ({ default: mod.Admin })));
return () => {
const auth = useAuth();
const [loaded, setLoaded] = useState(false);
useEffect(() => {
if (typeof window === "undefined") return;
setLoaded(true);
}, []);
if (!loaded) return null;
return (
<Suspense>
<Admin withProvider={{ user: auth.user }} {...props} />
</Suspense>
);
};
}

View File

@@ -1,2 +0,0 @@
export * from "./remix.adapter";
export * from "./AdminPage";