UNPKG

@hono-filebased-route/core

Version:

A core utility for file-based routing in Hono applications.

50 lines (46 loc) 1.52 kB
// Generated by dts-bundle-generator v9.5.1 import pino from 'pino'; declare const METHODS: readonly [ "GET", "POST" ]; export type Method = (typeof METHODS)[number]; export type ExportedMethods = { [key in Method]: boolean; }; export type Config = { dir: string; output: string; write: boolean; verbose: boolean; externals: string[]; typescript: boolean; }; /** * 遍历指定目录并获取所有文件路径 * @param dir 要遍历的目录 * @returns 目录内所有文件绝对路径的数组 */ export declare function getFiles(dir: string, externals?: string[]): Promise<string[]>; /** * 将文件路径转换为 Hono 路由路径 * @param filePath 文件的绝对路径 * @param baseDir 路由文件的根目录的绝对路径 * @returns 转换后的 Hono 路由路径 */ export declare function getRoutePath(filePath: string, baseDir: string): string; /** * 从文件中提取导出的 HTTP 方法 * @param filePath 文件的绝对路径 * @returns 导出的 HTTP 方法对象 */ export declare function getExportedHttpMethods(filePath: string): ExportedMethods; /** * 从文件中提取导出的 MiddlewareHandler config * @param filePath 文件的绝对路径 * @returns 是否导出 MiddlewareHandler */ export declare function getExportedMiddlewareHandler(filePath: string): ExportedMethods; export declare function generateRoutesFile(config?: Partial<Config>): Promise<string>; export declare const createLogger: (verbose?: boolean) => pino.Logger<never, boolean>; export {};