stackvana / microcule

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

Create plugin system / Refactor schema and view-presenter into plugins #4

Closed Marak closed 8 years ago

Marak commented 8 years ago

Since all logic for spawning services are essentially stream transformations, we should remove the optional schema and view-presenter and move them into optional plugins.

In order to do this, we'll need a simple .use or .pipe pattern for adding stream transformation plugins.

Marak commented 8 years ago

After brief consideration, I realize that since we are mostly using express based http servers, we don't have to re-invent any kind of plugin system.

I've created a new branch v3.0.0 which removes all non-core spawning logic and places into simple node.js middlewares function (req, res, next) {}. These can be app.use() in express.

Here is what a really simple logger middleware / "plugin" would look like:

module.exports = function (config) {
  return function loggerHandler (req, res, next) {
    console.log('running service ' + req.url);
    next();
  }
}

If anyone has any ideas or pull requests for default plugins / HTTP middlewares which should be included in the project, please let me know.

Marak commented 8 years ago

This is resolved and merged into master.

Looks good!