diff --git a/app.js b/app.js index c38f8bd..a052e70 100644 --- a/app.js +++ b/app.js @@ -16,7 +16,7 @@ var env = process.env.NODE_ENV || 'development', var app = new EventEmitter(), logger = libLogger('app'), - httpApi = require('./httpApi')(app); + httpApi; var staticPath = path.join(__dirname, 'static'), staticServer = new nodeStatic.Server(staticPath); @@ -56,6 +56,7 @@ app.lib = {}; app.lib.reader = reader; app.lib.notifier = notifier; app.lib.logger = libLogger; +app.lib.project = project; var configDefaults = { notify: {}, @@ -214,6 +215,8 @@ Steppy( require(plugin).register(app); }); + httpApi = require('./httpApi')(app); + notifier.init(app.config.notify, this.slot()); require('./projectsWatcher').init(app, this.slot()); diff --git a/httpApi.js b/httpApi.js index b9ee8f1..69bba58 100644 --- a/httpApi.js +++ b/httpApi.js @@ -2,10 +2,7 @@ var Steppy = require('twostep').Steppy, _ = require('underscore'), - querystring = require('querystring'), - logger = require('./lib/logger')('http api'), - project = require('./lib/project'); - + querystring = require('querystring'); /* * Pure rest api on pure nodejs follows below */ @@ -51,6 +48,7 @@ router.getRoute = function(req) { }; module.exports = function(app) { + var logger = app.lib.logger('http api'); // run building of a project router.post('/api/1.0/builds', function(req, res, next) { @@ -83,7 +81,7 @@ module.exports = function(app) { Steppy( function() { logger.log('Cleaning up project "%s"', projectName); - project.remove({ + app.lib.project.remove({ baseDir: app.config.paths.projects, name: projectName }, this.slot()); @@ -122,7 +120,7 @@ module.exports = function(app) { ); } - project.rename({ + app.lib.project.rename({ baseDir: app.config.paths.projects, name: projectName, newName: newProjectName