Tag Info

New answers tagged

2

Both solutions can make sense. Using functions as parameters is useful in many cases, and this generally makes it easier to write correct code because you're forced to provide callbacks for all circumstances. However, an API that requires callbacks tend to create unnecessarily deep indentation. This becomes more obvious when we have more than one validation, ...


2

Wouldn't it be simpler to pass the callback to connection.query around? // model function listCountries(limit, offset, callback) { // SQL is just an example connection.query('SELECT * FROM countries LIMIT 1', callback); } // controller var Country = require('./country.model'); exports.index = function(req, res) { var limit, offset; ...


5

Separation of concerns. The concern of templates is visual display of information. Business logic doesn't play any part in that. User interfaces can contain short loops that iterate over lists. It can also contain validation logic and things like AJAX that improve interactivity. Beyond that, it's generally all server-side, unless the application is ...


0

You should try doing this with api chaining and loopback http://www.slideshare.net/bobdobbes/api-abstraction-api-chaining



Top 50 recent answers are included