http api uses deps via app

This commit is contained in:
oleg 2015-12-06 23:46:24 +03:00
parent fbdfc28129
commit a481334759
2 changed files with 8 additions and 7 deletions

5
app.js
View File

@ -16,7 +16,7 @@ var env = process.env.NODE_ENV || 'development',
var app = new EventEmitter(), var app = new EventEmitter(),
logger = libLogger('app'), logger = libLogger('app'),
httpApi = require('./httpApi')(app); httpApi;
var staticPath = path.join(__dirname, 'static'), var staticPath = path.join(__dirname, 'static'),
staticServer = new nodeStatic.Server(staticPath); staticServer = new nodeStatic.Server(staticPath);
@ -56,6 +56,7 @@ app.lib = {};
app.lib.reader = reader; app.lib.reader = reader;
app.lib.notifier = notifier; app.lib.notifier = notifier;
app.lib.logger = libLogger; app.lib.logger = libLogger;
app.lib.project = project;
var configDefaults = { var configDefaults = {
notify: {}, notify: {},
@ -214,6 +215,8 @@ Steppy(
require(plugin).register(app); require(plugin).register(app);
}); });
httpApi = require('./httpApi')(app);
notifier.init(app.config.notify, this.slot()); notifier.init(app.config.notify, this.slot());
require('./projectsWatcher').init(app, this.slot()); require('./projectsWatcher').init(app, this.slot());

View File

@ -2,10 +2,7 @@
var Steppy = require('twostep').Steppy, var Steppy = require('twostep').Steppy,
_ = require('underscore'), _ = require('underscore'),
querystring = require('querystring'), querystring = require('querystring');
logger = require('./lib/logger')('http api'),
project = require('./lib/project');
/* /*
* Pure rest api on pure nodejs follows below * Pure rest api on pure nodejs follows below
*/ */
@ -51,6 +48,7 @@ router.getRoute = function(req) {
}; };
module.exports = function(app) { module.exports = function(app) {
var logger = app.lib.logger('http api');
// run building of a project // run building of a project
router.post('/api/1.0/builds', function(req, res, next) { router.post('/api/1.0/builds', function(req, res, next) {
@ -83,7 +81,7 @@ module.exports = function(app) {
Steppy( Steppy(
function() { function() {
logger.log('Cleaning up project "%s"', projectName); logger.log('Cleaning up project "%s"', projectName);
project.remove({ app.lib.project.remove({
baseDir: app.config.paths.projects, baseDir: app.config.paths.projects,
name: projectName name: projectName
}, this.slot()); }, this.slot());
@ -122,7 +120,7 @@ module.exports = function(app) {
); );
} }
project.rename({ app.lib.project.rename({
baseDir: app.config.paths.projects, baseDir: app.config.paths.projects,
name: projectName, name: projectName,
newName: newProjectName newName: newProjectName