From 3cd93315ea5763b9912e6357b95ef071bbdd5bb1 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Thu, 18 Sep 2014 14:21:38 +0100 Subject: [PATCH] refactor --- app.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index 842cb385..d9659b17 100644 --- a/app.js +++ b/app.js @@ -8,13 +8,24 @@ app.use( require('./middleware/headers') ); app.use( require('./middleware/cors') ); app.use( require('./middleware/jsonp') ); +/** ----------------------- sanitisers ----------------------- **/ + +var sanitisers = {}; +sanitisers.suggest = require('./sanitiser/suggest'); + +/** ----------------------- controllers ----------------------- **/ + +var controllers = {}; +controllers.index = require('./controller/index'); +controllers.suggest = require('./controller/suggest'); + /** ----------------------- routes ----------------------- **/ // api root -app.get( '/', require('./controller/index')() ); +app.get( '/', controllers.index() ); // suggest API -app.get( '/suggest', require('./sanitiser/suggest').middleware, require('./controller/suggest')() ); +app.get( '/suggest', sanitisers.suggest.middleware, controllers.suggest() ); /** ----------------------- error middleware ----------------------- **/