2022-07-02 06:09:45 +00:00
|
|
|
export const METHOD_NAME_ALL = 'ALL' as const
|
|
|
|
export const METHOD_NAME_ALL_LOWERCASE = 'all' as const
|
2023-06-03 00:07:33 +00:00
|
|
|
export const METHODS = ['get', 'post', 'put', 'delete', 'options', 'patch'] as const
|
2022-07-02 06:09:45 +00:00
|
|
|
|
|
|
|
export interface Router<T> {
|
2023-05-17 15:05:28 +00:00
|
|
|
name: string
|
2022-07-02 06:09:45 +00:00
|
|
|
add(method: string, path: string, handler: T): void
|
|
|
|
match(method: string, path: string): Result<T> | null
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface Result<T> {
|
|
|
|
handlers: T[]
|
|
|
|
params: Record<string, string>
|
|
|
|
}
|
2022-09-12 11:49:18 +00:00
|
|
|
|
|
|
|
export class UnsupportedPathError extends Error {}
|