nci/resources/projects.js

33 lines
775 B
JavaScript
Raw Normal View History

2015-04-10 19:23:52 +00:00
'use strict';
var Steppy = require('twostep').Steppy,
createBuildDataResource = require('../distributor').createBuildDataResource,
2015-07-05 18:03:58 +00:00
logger = require('../lib/logger')('projects resource');
2015-04-12 22:19:42 +00:00
2015-05-12 20:12:28 +00:00
module.exports = function(app) {
2015-04-12 22:41:09 +00:00
var resource = app.dataio.resource('projects'),
distributor = app.distributor;
2015-05-10 10:04:54 +00:00
2015-05-14 20:37:44 +00:00
resource.use('createBuildDataResource', function(req, res) {
createBuildDataResource({id: req.data.id});
res.send();
});
2015-05-17 13:48:16 +00:00
resource.use('readAll', function(req, res) {
res.send(app.projects);
2015-04-12 22:41:09 +00:00
});
resource.use('run', function(req, res) {
2015-06-13 18:59:32 +00:00
var projectName = req.data.projectName;
2015-07-05 18:03:58 +00:00
logger.log('Run the project: "%s"', projectName);
2015-06-14 14:21:04 +00:00
distributor.run({
projectName: projectName,
initiator: {type: 'user'}
2015-07-05 18:03:58 +00:00
});
res.send();
});
return resource;
2015-04-10 19:23:52 +00:00
};