Validating & Sanitizing Input
module.exports = ResourceController.extend ({
// ...
getOne () {
return Action.extend ({
// express-validator schema
schema: {
[this.id]: {
in: 'params',
optional: false,
}
},
execute (req, res) {
const { rentalId } = req.params;
const rental = this.controller.rentals.get (rentalId);
if (rental) {
res.status (200).json ({ data: [rental] });
}
else {
res.sendStatus (404);
}
}
})
}
});