2019-08-31 04:07:25 +05:00
|
|
|
module.exports = {
|
|
|
|
inputs: {
|
|
|
|
criteria: {
|
|
|
|
type: 'json',
|
2019-11-05 18:01:42 +05:00
|
|
|
required: true,
|
|
|
|
},
|
2019-08-31 04:07:25 +05:00
|
|
|
},
|
|
|
|
|
|
|
|
exits: {
|
2019-11-05 18:01:42 +05:00
|
|
|
notFound: {},
|
2019-08-31 04:07:25 +05:00
|
|
|
},
|
|
|
|
|
2019-11-05 18:01:42 +05:00
|
|
|
async fn(inputs, exits) {
|
2019-08-31 04:07:25 +05:00
|
|
|
const task = await Task.findOne(inputs.criteria);
|
|
|
|
|
|
|
|
if (!task) {
|
|
|
|
throw 'notFound';
|
|
|
|
}
|
|
|
|
|
|
|
|
const path = await sails.helpers
|
|
|
|
.getCardToProjectPath(task.cardId)
|
2019-11-05 18:01:42 +05:00
|
|
|
.intercept('notFound', (nodes) => ({
|
2019-08-31 04:07:25 +05:00
|
|
|
notFound: {
|
|
|
|
task,
|
2019-11-05 18:01:42 +05:00
|
|
|
...nodes,
|
|
|
|
},
|
2019-08-31 04:07:25 +05:00
|
|
|
}));
|
|
|
|
|
|
|
|
return exits.success({
|
|
|
|
task,
|
2019-11-05 18:01:42 +05:00
|
|
|
...path,
|
2019-08-31 04:07:25 +05:00
|
|
|
});
|
2019-11-05 18:01:42 +05:00
|
|
|
},
|
2019-08-31 04:07:25 +05:00
|
|
|
};
|