From ba91d7aba677c0ea32232206daece5dd6a8ae7dd Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Sun, 24 Aug 2014 12:30:49 -0400 Subject: [PATCH] proof-of-concept for hot-swapping of routes --- src/hotswap.js | 33 +++++++++++++++ src/plugins.js | 34 ++++++++++++++- src/routes/debug.js | 6 ++- src/routes/index.js | 100 +++++++++++++++++++++++--------------------- src/webserver.js | 1 + 5 files changed, 123 insertions(+), 51 deletions(-) create mode 100644 src/hotswap.js diff --git a/src/hotswap.js b/src/hotswap.js new file mode 100644 index 0000000000..717c099052 --- /dev/null +++ b/src/hotswap.js @@ -0,0 +1,33 @@ +var HotSwap = {}, + winston = require('winston'), + stack; + +HotSwap.prepare = function(app) { + stack = app._router.stack; +}; + +HotSwap.find = function(id) { + if (stack) { + for(var x=0,numEntries=stack.length;x