You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
590 B
JavaScript
35 lines
590 B
JavaScript
module.exports = {
|
|
inputs: {
|
|
criteria: {
|
|
type: 'json',
|
|
required: true,
|
|
},
|
|
},
|
|
|
|
exits: {
|
|
pathNotFound: {},
|
|
},
|
|
|
|
async fn(inputs, exits) {
|
|
const attachment = await Attachment.findOne(inputs.criteria);
|
|
|
|
if (!attachment) {
|
|
throw 'pathNotFound';
|
|
}
|
|
|
|
const path = await sails.helpers
|
|
.getCardToProjectPath(attachment.cardId)
|
|
.intercept('pathNotFound', (nodes) => ({
|
|
pathNotFound: {
|
|
attachment,
|
|
...nodes,
|
|
},
|
|
}));
|
|
|
|
return exits.success({
|
|
attachment,
|
|
...path,
|
|
});
|
|
},
|
|
};
|