From 944b946e05a0e0acbcfc29b15e53dc76e7b05581 Mon Sep 17 00:00:00 2001 From: Alex Shatov Date: Thu, 28 Sep 2017 09:20:14 -0400 Subject: 4.2.2. fixed starting up of deployment-handler * start of dh was broken by coding for unit-test * Coverage summary Statements : 50.84% ( 514/1011 ) Branches : 26.11% ( 100/383 ) Functions : 30.11% ( 56/186 ) Lines : 51.35% ( 513/999 ) Change-Id: Ibb59f1ddd25a37a7bd58f4017837a622b04381e3 Issue-Id: DCAEGEN2-62 Signed-off-by: Alex Shatov --- deployment-handler.js | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'deployment-handler.js') diff --git a/deployment-handler.js b/deployment-handler.js index 171f73c..1d59733 100644 --- a/deployment-handler.js +++ b/deployment-handler.js @@ -36,24 +36,26 @@ const SWAGGER_UI_PATH = "/swagger-ui"; const app = express(); -/* Set up the application */ -app.set('x-powered-by', false); -app.set('etag', false); +const set_app = function() { + /* Set up the application */ + app.set('x-powered-by', false); + app.set('etag', false); -/* Give each request a unique request ID */ -app.use(require('./lib/middleware').assignId); + /* Give each request a unique request ID */ + app.use(require('./lib/middleware').assignId); -/* If authentication is set up, check it */ -app.use(require('./lib/auth').checkAuth); + /* If authentication is set up, check it */ + app.use(require('./lib/auth').checkAuth); -/* Set up API routes */ -app.use(INFO_PATH, require('./lib/info')); -app.use(DEPLOYMENTS_PATH, require('./lib/dcae-deployments')); -app.use(POLICY_PATH, require('./lib/policy')); -app.use(SWAGGER_UI_PATH, require('./lib/swagger-ui')); + /* Set up API routes */ + app.use(INFO_PATH, require('./lib/info')); + app.use(DEPLOYMENTS_PATH, require('./lib/dcae-deployments')); + app.use(POLICY_PATH, require('./lib/policy')); + app.use(SWAGGER_UI_PATH, require('./lib/swagger-ui')); -/* Set up error handling */ -app.use(require('./lib/middleware').handleErrors); + /* Set up error handling */ + app.use(require('./lib/middleware').handleErrors); +} const start = function(config) { @@ -77,6 +79,8 @@ const start = function(config) { log.debug(null, "Configuration: " + JSON.stringify(config)); + set_app(); + /* Start the server */ var server = null; var usingTLS = false; @@ -149,4 +153,5 @@ conf.configure() console.error("Deployment-handler exiting due to startup problem: " + e.message); }); -module.exports = app; \ No newline at end of file +module.exports.app = app; +module.exports.set_app = set_app; -- cgit 1.2.3-korg