rasengan
Version:
The modern React Framework
31 lines (30 loc) • 1.01 kB
TypeScript
import { FunctionComponent } from 'react';
import { RouterComponent } from '../interfaces.js';
import { Metadata } from '../types.js';
export type RouteNode = {
path: string;
segment: string;
fullPath: string;
isLayout?: boolean;
module?: () => Promise<Module>;
component?: FunctionComponent<any>;
metadata?: Metadata;
children?: RouteNode[];
source?: string;
};
export type Module = {
default: FunctionComponent<any>;
};
/**
* Get path segments from file path
* @param filePath File path
* @param foldersOnly Whether to return only folders
* @returns Path segments
*/
export declare function getPathSegments(filePath: string, foldersOnly?: boolean): string[];
/**
* This function receives a function that returns a record of modules and generate a router component
* @param fn Function that returns a record of modules
* @returns Router component
*/
export declare function flatRoutes(fn: () => Record<string, () => Promise<Module>>): Promise<RouterComponent>;