Skip to content

nujii/architect-request

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

architect-request

request plugin for architect

Config Format

{
  "packagePath": "./node_modules/architect-request"
}

Usage

Go to town on that sucker

module.exports = function (options, imports, register) {

  var request = imports.request;

  request('http://google.com', function(error, response, body){
    // handle the response
  });

};

TODO

It would be nice to create a fixure for request testing.

We would be able to define routes similar to express:

var requestSpoof = new request.fixture();
requestSpoof.get('http://api.example.com', req, res) {
  res.send(JSON.stringify({hello: "world"}));
};

We can set up our tests like this:

var imports = {
  request: requestSpoof
};

require('other-plugin')({}, imports, register);

And in a test case:

it('should consume the api', function(done)) {
  // This module would make a call to 'http://api.example.com' and
  // parse the returned json
  moduleThatDependsOnRequest.get(function(err, obj){
    should.not.exist(err);
    should.exist(obj);
    should.exist(obj.hello);
    obj.hello.should.equal("world");
  });
}

About

HTTP Request plugin for Architect

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published