UNPKG

reblend-routing

Version:

Reblend route pattern matcher

53 lines (52 loc) 1.27 kB
/*! * express * Copyright(c) 2009-2013 TJ Holowaychuk * Copyright(c) 2013 Roman Shtylman * Copyright(c) 2014-2015 Douglas Christopher Wilson * Copyright(c) 2024 Emmanuel Paul Elom * MIT Licensed */ import { Key } from 'path-to-regexp'; import Route from './Route'; import Request from '../Request'; /** * Module exports. * @public */ export default class Layer { handle: Function; name: string; params: Record<string, any> | undefined; path: string | undefined; keys: Key[]; regexp: any; route?: Route; method?: string; constructor(path: string, options: Record<string, any>, fn: Function); /** * Handle the error for the layer. * * @param {Error} error * @param {Request} req * @param {function} next * @api private */ handle_error(error: Error, req: any, next: Function): void; /** * Handle the request for the layer. * * @param {Request} req * @param {function} next * @api private */ handle_request(req: Request, next: Function): void; /** * Check if this route matches `path`, if so * populate `.params`. * * @param {String} path * @return {Boolean} * @api private */ match(path: string): boolean; }