diff options
Diffstat (limited to 'deployment-handler.js')
-rw-r--r-- | deployment-handler.js | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/deployment-handler.js b/deployment-handler.js index 01455d4..171f73c 100644 --- a/deployment-handler.js +++ b/deployment-handler.js @@ -34,6 +34,27 @@ const DEPLOYMENTS_PATH = "/dcae-deployments"; const POLICY_PATH = "/policy"; const SWAGGER_UI_PATH = "/swagger-ui"; +const app = express(); + +/* 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); + +/* 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 error handling */ +app.use(require('./lib/middleware').handleErrors); + const start = function(config) { const startTime = new Date(); @@ -56,26 +77,6 @@ const start = function(config) { log.debug(null, "Configuration: " + JSON.stringify(config)); - /* Set up the application */ - const app = express(); - app.set('x-powered-by', false); - app.set('etag', false); - - /* 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); - - /* 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); - /* Start the server */ var server = null; var usingTLS = false; @@ -105,7 +106,7 @@ const start = function(config) { server.listen(config.listenPort, config.listenHost, function(err) { var addr = server.address(); - var msg = ("Dispatcher version " + config.version + " listening on " + var msg = ("Deployment-handler version " + config.version + " listening on " + addr.address + ":" + addr.port + " pid: " + process.pid + (usingTLS ? " " : " not ") + "using TLS (HTTPS)"); log.metrics(null, {startTime: startTime, complete: true}, msg); @@ -143,7 +144,9 @@ conf.configure() .then(start) .catch(function(e) { log.error(e.logCode ? e : createError( - 'Dispatcher exiting due to start-up problem: ' + e.message, 500, + 'Deployment-handler exiting due to start-up problem: ' + e.message, 500, 'system', 552)); - console.error("Dispatcher exiting due to startup problem: " + e.message); -});
\ No newline at end of file + console.error("Deployment-handler exiting due to startup problem: " + e.message); +}); + +module.exports = app;
\ No newline at end of file |