0.4.1 • Published 4 years ago

stubrec v0.4.1

Weekly downloads
184
License
MIT
Repository
github
Last release
4 years ago

Stubrec Build Status

Stubrec records json file and proxy request and response.

Usage

$ npm install stubrec -S
var Stubrec = require('stubrec');
var stubrec = new Stubrec({
  // proxy property specifies backend server
  proxy : "http://localhost:3001", 
  // debug print on
  debug : true
});
var http = require("http");

http.createServer(function(req, res){
    //record to ./test/test.json
    stubrec.record("./test/test.json", req, res);
}).listen(3000);

http.createServer(function(req, res){
    res.writeHead(200, {'Content-Type': 'application/json'});
    res.end('{"hello":"world"}');
}).listen(3001);

http.get("http://localhost:3000/", function(res){
    var data = '';
    res.on("data", function(chunk){
      data += chunk;
    });
    res.on("end", function(){
      // {"hello":"world"}
      console.log(data);
      done();
    });
});
0.4.1

4 years ago

0.3.0

10 years ago

0.2.3

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago