mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-17 04:46:05 +00:00
replaced remix with react-router
This commit is contained in:
1
app/src/adapter/react-router/index.ts
Normal file
1
app/src/adapter/react-router/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./react-router.adapter";
|
||||
@@ -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);
|
||||
@@ -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>
|
||||
);
|
||||
};
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
export * from "./remix.adapter";
|
||||
export * from "./AdminPage";
|
||||
Reference in New Issue
Block a user