const Errors = { CARD_NOT_FOUND: { cardNotFound: 'Card not found', }, }; module.exports = { inputs: { id: { type: 'string', regex: /^[0-9]+$/, required: true, }, }, exits: { cardNotFound: { responseType: 'notFound', }, }, async fn(inputs, exits) { const { currentUser } = this.req; const { card, project } = await sails.helpers .getCardToProjectPath(inputs.id) .intercept('pathNotFound', () => Errors.CARD_NOT_FOUND); const isUserMemberForProject = await sails.helpers.isUserMemberForProject( project.id, currentUser.id, ); if (!isUserMemberForProject) { throw Errors.CARD_NOT_FOUND; // Forbidden } return exits.success({ item: card, }); }, };