UNPKG

reblend-routing

Version:

Reblend route pattern matcher

64 lines (63 loc) 1.54 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 { Request } from '../index'; /** * Module exports. * @public */ export default class Route { path: string; stack: any[]; methods: Record<string, boolean>; [method: string]: any; constructor(path: string); /** * Determine if the route handles a given method. * @private */ _handles_method(method: string): boolean; /** * @return {Array} supported HTTP methods * @private */ _options(): string[]; /** * dispatch req into this route * @private */ dispatch(req: Request, done: (err?: any) => void): void; /** * Add a handler for all HTTP verbs to this route. * * Behaves just like middleware and can respond or call `next` * to continue processing. * * You can use multiple `.all` call to add multiple handlers. * * function check_something(req, res, next){ * next(); * }; * * function validate_user(req, res, next){ * next(); * }; * * route * .all(validate_user) * .all(check_something) * .get(function(req, res, next){ * res.send('hello world'); * }); * * @param {function} handler * @return {Route} for chaining * @api public */ all(...handlers: Function[]): Route; }