text: 'use strict';
  
  exports = module.exports = function(req, res) {
    var workflow = new (require('events').EventEmitter)();
  
    workflow.outcome = {
      success: false,
      errors: [],
      errfor: {},
      infos:[]
    };
  
    workflow.hasErrors = function() {
      return Object.keys(workflow.outcome.errfor).length !== 0 || workflow.outcome.errors.length !== 0;
    };
  
    workflow.on('exception', function(err) {
      workflow.outcome.errors.push('Exception: '+ err);
      return workflow.emit('response');
    });
  
    workflow.on('response', function() {
      workflow.outcome.success = !workflow.hasErrors();
      res.header('Cache-Control', 'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0');
      res.send(workflow.outcome);
    });
  
    return workflow;
  };
  