UNPKG

@zenweb/router

Version:

Zenweb Router module

34 lines (33 loc) 847 B
import { Middleware } from "@zenweb/core"; export type RouterPath = string | RegExp | (string | RegExp)[]; export type RouterMethod = 'GET' | 'POST' | 'PUT' | 'LINK' | 'UNLINK' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'PATCH' | 'ALL'; export type RouterParams = Record<string, string>; export interface RouterMatch { params: RouterParams; handler: Middleware; } export interface RouterOptions { /** * URL 前缀 */ prefix?: string; } export interface RouterRegisterOption { /** * 在路由中增加前缀 * - 主要解决正则表达式添加前缀字符串问题 */ prefix?: string; /** * 路由路径 */ path: RouterPath; /** * 路由方法 */ method: RouterMethod | RouterMethod[]; /** * 路由中间件 */ middleware: Middleware | Middleware[]; }