UNPKG

@iopa/router

Version:

Lightweight and fast router for IOPA applications

19 lines (14 loc) 453 B
import type { IRouterResult, IRouter } from '@iopa/types' import { Node } from './node' export class TrieRouter<T> implements IRouter<T> { public node: Node<T> public constructor() { this.node = new Node() } public add(method: string, path: string, handler: T): void { this.node.insert(method, path, handler) } public match(method: string, path: string): IRouterResult<T> | null { return this.node.search(method, path) } }