refactor(router): introduce app navigation manager
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { ROUTES } from "./routes";
|
||||
|
||||
export type RouteAccess = "public" | "session" | "realUser" | "authOnly";
|
||||
|
||||
const STATIC_ROUTE_ACCESS: Partial<Record<string, RouteAccess>> = {
|
||||
[ROUTES.root]: "public",
|
||||
[ROUTES.splash]: "authOnly",
|
||||
[ROUTES.auth]: "authOnly",
|
||||
[ROUTES.chat]: "session",
|
||||
[ROUTES.sidebar]: "session",
|
||||
[ROUTES.subscription]: "realUser",
|
||||
[ROUTES.coinsRules]: "public",
|
||||
};
|
||||
|
||||
export function getRouteAccess(pathname: string): RouteAccess {
|
||||
if (pathname.startsWith("/chat/image/")) return "session";
|
||||
if (pathname.startsWith("/chat/deviceid/")) return "public";
|
||||
return STATIC_ROUTE_ACCESS[pathname] ?? "public";
|
||||
}
|
||||
|
||||
export function isInternalRoute(value: string | null | undefined): boolean {
|
||||
return Boolean(value && value.startsWith("/") && !value.startsWith("//"));
|
||||
}
|
||||
Reference in New Issue
Block a user