stackvana / microcule

SDK and CLI for spawning streaming stateless HTTP microservices in multiple programming languages
Other
479 stars 29 forks source link

Update node.js function signature #25

Open Marak opened 7 years ago

Marak commented 7 years ago

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 commented 7 years ago

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.