microcule icon indicating copy to clipboard operation
microcule copied to clipboard

Update node.js function signature

Open Marak opened this issue 8 years ago • 1 comments

Currently, the signature for Node.js functions is: function (hook).

It would be more clear to users and node.js friendly if the signature was: function(req, res).

The new function signature would actually be backwards compatible, so this wouldn't break any existing services. Update will be required in run-service npm package.

We could also consider function(req, res, next), but implementing next correctly might be non-trivial.

Marak avatar Jan 20 '17 15:01 Marak

We've got good progress on this in the service-as-middleware branch.

It appears we've got working support for function (req, res, next) signatures to the point where we can chain multiple services together as middlewares.

I've checked in some examples in service-as-middleware for putting a basicAuth service behind others services.

Should be merged into master after more testing downstream in hook.io.

Marak avatar Feb 24 '17 22:02 Marak