Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

iso-call

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iso-call - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

examples/03-context/app.js

2

examples/02-yql/app.js

@@ -32,3 +32,3 @@ require('iso-call/polyfill');

renderInto: function (form) {
this.get(form.elements.query.value).then(function (H) {
this.get(form.elements.q.value).then(function (H) {
form.innerHTML = H;

@@ -35,0 +35,0 @@ });

@@ -15,3 +15,3 @@ var isoreq = require('./iso-request-core');

if (!URL) {
return Promise.reject('call isocall.request() on api: "' + cfg.name + '" without URL!');
return Promise.reject(new Error('call isocall.request() on api: "' + cfg.name + '" without URL!'));
}

@@ -18,0 +18,0 @@

@@ -15,11 +15,8 @@ var isoconfig = require('./iso-config');

'content-type': 'application/json'
}
},
json: true
})).then(function (R) {
try {
return JSON.parse(R.body);
} catch (E) {
return R.body;
}
return R.body.rpc;
});
}
};

@@ -17,3 +17,3 @@ var execute = function (name, cfg) {

try {
return Promise.resolve(exec(cfg));
return Promise.resolve(exec.apply(this, [cfg]));
} catch (E) {

@@ -25,4 +25,4 @@ return Promise.reject(E);

var middleware = function (req, res) {
execute(req.params.name, req.body).then(function (R) {
res.send(R);
execute.apply(req, [req.params.name, req.body]).then(function (R) {
res.send({rpc: R});
})['catch'](function (E) {

@@ -29,0 +29,0 @@ console.warn(E.stack);

{
"name": "iso-call",
"version": "0.0.1",
"version": "0.0.2",
"description": "Isomorphic api call for any nodejs/express application",

@@ -24,3 +24,3 @@ "author": "Zordius <zordius@yahoo-inc.com>",

"middleware",
"gulp"
"RPC"
],

@@ -27,0 +27,0 @@ "scripts": {

@@ -6,3 +6,3 @@ iso-call

[![Build Status](https://travis-ci.org/zordius/iso-call.svg?branch=master)](https://travis-ci.org/zordius/iso-call) [![Test Coverage](https://codeclimate.com/github/zordius/iso-call/badges/coverage.svg)](https://codeclimate.com/github/zordius/iso-call) [![Code Climate](https://codeclimate.com/github/zordius/iso-call/badges/gpa.svg)](https://codeclimate.com/github/zordius/iso-call) [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE.txt)
[![npm version](https://img.shields.io/npm/v/iso-call.svg)](https://www.npmjs.org/package/iso-call) [![Build Status](https://travis-ci.org/zordius/iso-call.svg?branch=master)](https://travis-ci.org/zordius/iso-call) [![Test Coverage](https://codeclimate.com/github/zordius/iso-call/badges/coverage.svg)](https://codeclimate.com/github/zordius/iso-call) [![Code Climate](https://codeclimate.com/github/zordius/iso-call/badges/gpa.svg)](https://codeclimate.com/github/zordius/iso-call) [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE.txt)

@@ -24,2 +24,3 @@ Installation

```
Add these into your `package.json` to enable aliasify:

@@ -122,1 +123,6 @@

Check our <a href="examples/02-yql">YQL example</a> to know more about isocall.request().
Use Case: deal with request by context
--------------------------------------
Checkout our <a href="examples/03-context">Context example</a> to know more about context based RPC which can access request by `this`.

@@ -31,3 +31,3 @@ var assert = require('chai').assert;

it('will make PUT request to baseURL', function (done) {
nock(baseHOST).persist().put('/test').reply(200, {msg: 'OK!'});
nock(baseHOST).persist().put('/test').reply(200, {rpc: {msg: 'OK!'}});

@@ -34,0 +34,0 @@ isoexe.execute('test').then(function (R) {

@@ -105,3 +105,3 @@ var assert = require('chai').assert;

send: function (body) {
assert.equal(body, 'BODY!');
assert.deepEqual(body, {rpc: 'BODY!'});
done();

@@ -108,0 +108,0 @@ }

var assert = require('chai').assert;
var isoreq = require('../lib/iso-request-server');
var isoexe = require('../lib/iso-execute-server');
var isocfg = require('../lib/iso-config');
var sinon = require('sinon');
var nock = require('nock');
describe('iso-request-server', function () {
before(function () {
nock.disableNetConnect();
});
after(function () {
nock.enableNetConnect();
});
afterEach(function () {
nock.cleanAll();
if (isoexe.execute.restore) {

@@ -13,2 +24,14 @@ isoexe.execute.restore();

it('.request() should return rejected promise when NO name provided', function (done) {
isoreq.request().catch(function (E) {
assert.deepEqual(E.message, 'iso-request-server without name!');
}).then(done.bind(), done);
});
it('.request() should return rejected promise when NO url provided', function (done) {
isoreq.request('test').catch(function (E) {
assert.deepEqual(E.message, 'call isocall.request() on api: "test" without URL!');
}).then(done.bind(), done);
});
it('should isoexe.execute() with default request RPC name', function (done) {

@@ -24,2 +47,11 @@ sinon.stub(isoexe, 'execute').returns(Promise.resolve());

});
it('should isoreq() then receive result', function (done) {
nock('http://abc').persist().get('/?a=b').reply(200, 'OK!');
isocfg.addConfigs({test: 'http://abc/'});
isoreq.request('test', {qs: {a: 'b'}}).then(function (R) {
assert.equal(R.body, 'OK!');
}).then(done.bind(), done);
});
});
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