Files
planka/server/api/helpers/get-action-to-project-path.js
Maksim Eltyshev 36fe34e8e1 Initial commit
2019-08-31 04:07:25 +05:00

35 lines
549 B
JavaScript
Executable File

module.exports = {
inputs: {
criteria: {
type: 'json',
required: true
}
},
exits: {
notFound: {}
},
fn: async function(inputs, exits) {
const action = await Action.findOne(inputs.criteria);
if (!action) {
throw 'notFound';
}
const path = await sails.helpers
.getCardToProjectPath(action.cardId)
.intercept('notFound', path => ({
notFound: {
action,
...path
}
}));
return exits.success({
action,
...path
});
}
};