From d3af9e999386b1aaaf835935bdf291ed641b5e9b Mon Sep 17 00:00:00 2001 From: Daniel Lando Date: Wed, 27 May 2020 17:15:33 +0200 Subject: [PATCH] feat: removeAllRoutes public method This method allows to clear routes stack. As discussed here: https://github.com/expressjs/express/issues/4296 --- index.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/index.js b/index.js index 3608f26..cf106b3 100644 --- a/index.js +++ b/index.js @@ -435,6 +435,16 @@ Router.prototype.process_params = function process_params(layer, called, req, re param() } +/** + * Remove all paths from the current stack + * + * @public + */ + +Router.prototype.removeAllRoutes = function removeAllRoutes() { + this.stack = [] +} + /** * Use the given middleware function, with optional path, defaulting to "/". *