0

I'm new in noflo and I'd like to use it like expressjs middleware.
Each middleware will be separate noflo graph, which admin can change.
Is reasonable to use noflo like middleware and if yes how to convert function "registerUser" to noflo graph? Thnx.

function registerUser(req, res, next) {
    var serviceLocator = req.serviceLocator;
    serviceLocator.get('UserService').create(req.body, function(err, user) {
        if (err) {
            if (err.name === 'ValidationError') {
                res.send(403, err);
            } else {
                next(err);
            }
        } else {
            serviceLocator.get('EmailService').sendEmail('confirm-email', {user: user}, 
                function() {
                   res.send(user);
                }
            );
        }
    });
}
app.use('auth/register', registerUser);

1 Answers1

0

I am not familiar with express and what specific feature/behavior from express you'd like to apply to noflo. But what you can do is to setup several graphs, where each graph has a webserver component on the input side that listens for a specific path; 'auth/register' in your case. You could pass this as a IIP from your main app when setting up the graphs.

ensonic
  • 3,304
  • 20
  • 31