architect-request
Request plugin for Architect
Last updated 8 years ago by camshaft .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install architect-request 
SYNC missed versions from official npm registry.

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.encode({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");
  });
}

Current Tags

  • 0.0.1                                ...           latest (8 years ago)

1 Versions

  • 0.0.1                                ...           8 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |