nci/resources/projects.js

33 lines
775 B
JavaScript

'use strict';
var Steppy = require('twostep').Steppy,
createBuildDataResource = require('../distributor').createBuildDataResource,
logger = require('../lib/logger')('projects resource');
module.exports = function(app) {
var resource = app.dataio.resource('projects'),
distributor = app.distributor;
resource.use('createBuildDataResource', function(req, res) {
createBuildDataResource({id: req.data.id});
res.send();
});
resource.use('readAll', function(req, res) {
res.send(app.projects);
});
resource.use('run', function(req, res) {
var projectName = req.data.projectName;
logger.log('Run the project: "%s"', projectName);
distributor.run({
projectName: projectName,
initiator: {type: 'user'}
});
res.send();
});
return resource;
};