var app = require('express')();
var bodyParser = require('body-parser');
var cors = require('cors');
var responseStore = require('./lib/responseStore');
var requestStore = require('./lib/requestStore');

app.use(cors());
app.use(bodyParser.json());

var Simulado = function() {
    app.get('/', function(_, res) {
        res.send("Simulado running..");
    });

    app.get('/inspect', function(_, res) {
      res.send(responseStore.getAll());
    });

    app.all('*', function(req, res) {
        responseStore.find(req, function(mock) {
            if(mock) {
                requestStore.add(req);
                for(var header in mock.headers) {
                    res.header(header, mock.headers[header]);
                }
                res.status(mock.status).send(mock.response);
            } else {
                res.status(404).send({});
            }
        });
    });

    this.server = app.listen(7000)
    this.reset = function() {
        responseStore.reset();
        requestStore.reset();
    }
};

Simulado.prototype.mock = responseStore.add;
Simulado.prototype.lastRequest = requestStore.find;

module.exports = new Simulado();

@@ -921,16 +921,96 @@
 n(7000)%0A
+%0A    this.mock = responseStore.add;%0A%0A    this.lastRequest = requestStore.find;%0A%0A
     this
@@ -1102,107 +1102,10 @@
   %7D%0A
+%0A
 %7D
-;%0A%0ASimulado.prototype.mock = responseStore.add;%0ASimulado.prototype.lastRequest = requestStore.find
 ;%0A%0Am

Tidy up