New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

batch-request

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

batch-request - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

7

lib/batch-request.js

@@ -7,4 +7,3 @@ // Batch Request

Promise = require('bluebird'),
request = require('request'),
requestGet = Promise.promisify(request),
request = Promise.promisify(require('request')),
url = require('url');

@@ -33,3 +32,3 @@

if (!r.dependency || r.dependency === 'none') {
promises[key] = requestGet(r).spread(function(response, body) {
promises[key] = request(r).spread(function(response, body) {
return {

@@ -62,3 +61,3 @@ 'statusCode': response.statusCode,

requestPromises[dependentKey] = rp.then(function() {
return requestGet(dependent);
return request(dependent);
}).spread(function(response, body) {

@@ -65,0 +64,0 @@ return response;

{
"name": "batch-request",
"description": "Batch Request - Utility library to enable a server to handle batch requests",
"version": "0.0.4",
"version": "0.0.5",
"author": "Victor Quinn <mail@victorquinn.com>",

@@ -6,0 +6,0 @@ "homepage": "http://batch-request.socialradar.com",

@@ -8,3 +8,3 @@ Batch Request

[![Build Status](https://travis-ci.org/socialradar/batch-request.png?branch=master)](https://travis-ci.org/socialradar/batch-request)
[![Build Status](https://travis-ci.org/socialradar/batch-request.png?branch=master)](https://travis-ci.org/socialradar/batch-request) [![Built with Grunt](https://cdn.gruntjs.com/builtwith.png)](http://gruntjs.com/)

@@ -11,0 +11,0 @@ ## QuickStart

@@ -69,2 +69,42 @@ // Batch tests

it('will handle a POST with a body correctly', function(done) {
var first = chance.first();
request(app)
.post('/batch')
.send({
getName: {
method: 'POST',
body: { first: first },
json: true,
url: 'http://localhost:3000/users/1/name'
}
})
.expect(200, function(err, res) {
expect(err).to.not.exist;
expect(res.body).to.have.property('getName');
expect(res.body.getName.statusCode).to.equal(200);
expect(res.body.getName.body).to.be.a('string');
expect(res.body.getName.body).to.equal(first);
done();
});
});
it('will handle a PUT correctly', function(done) {
request(app)
.post('/batch')
.send({
getName: {
method: 'PUT',
url: 'http://localhost:3000/users/1/name'
}
})
.expect(200, function(err, res) {
expect(err).to.not.exist;
expect(res.body).to.have.property('getName');
expect(res.body.getName.statusCode).to.equal(200);
expect(res.body.getName.body).to.be.a('string');
done();
});
});
it('will handle deeply serialized objects on POST correctly', function(done) {

@@ -198,7 +238,7 @@ request(app)

time1: {
url: 'http://localhost:3000/users/1/hammertime'
url: 'http://localhost:3000/users/1/delay'
},
time2: {
dependency: 'time1',
url: 'http://localhost:3000/users/1/delay'
url: 'http://localhost:3000/users/1/hammertime'
}

@@ -209,3 +249,3 @@ })

var now = new Date().getTime();
// Expect first one to finish within
// Expect first one to finish within
expect(res.body.time1.body).to.be.within(now - 1000, now + 1000);

@@ -218,2 +258,25 @@ expect(res.body.time2.body).to.be.above(res.body.time1.body + 500);

it('will not choke on an empty string dependency', function(done) {
request(app)
.post('/batch')
.send({
time1: {
url: 'http://localhost:3000/users/1/delay'
},
time2: {
dependency: '',
url: 'http://localhost:3000/users/1/hammertime'
}
})
.expect(200, function(err, res) {
expect(err).to.not.exist;
var now = new Date().getTime();
// Expect first one to finish within
expect(res.body.time1.body).to.be.ok;
expect(res.body.time2.body).to.be.ok;
done();
});
});
it('will run chained dependencies, in order', function(done) {

@@ -220,0 +283,0 @@ request(app)

@@ -19,2 +19,12 @@ // Test app

app.post('/users/:id/name', function(req, res) {
// If a first name is sent in, we will reflect it so we can test that it was
// received correctly.
if (req.body.first) {
res.json(req.body.first);
} else {
res.json(chance.name());
}
});
app.put('/users/:id/name', function(req, res) {
res.json(chance.name());

@@ -47,6 +57,6 @@ });

app.get('/users/:id/delay', function(req, res, done) {
app.get('/users/:id/delay', function(req, res, next) {
setTimeout(function() {
res.json(new Date().getTime());
done();
next();
}, 250);

@@ -53,0 +63,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc