Socket
Socket
Sign inDemoInstall

trooba-xhr-transport

Package Overview
Dependencies
2
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 2.0.0

.github/CONTRIBUTING.md

26

index.js

@@ -10,17 +10,19 @@ /*jslint browser: true*/

*/
module.exports = function xhrTransportFactory(config) {
module.exports = function xhr(pipe, config) {
pipe.on('request', function onRequest(request) {
request = Utils.mixin(config,
request, {});
function xhr(requestContext, reply) {
requestContext.request = Utils.mixin(config,
requestContext.request, {});
invoke(request, function onResponse(err, response) {
if (err) {
pipe.throw(err);
return;
}
invoke(requestContext.request, function onResponse(err, response) {
if (response) {
Utils.deserializeResponseHeaders(response);
}
reply(err, response);
Utils.deserializeResponseHeaders(response);
pipe.respond(response);
});
}
});
return httpfy(xhr);
httpfy(pipe);
};

@@ -157,3 +159,3 @@

mixin: function mixin(src, target) {
if (src && typeof src === 'object') {
if (src && typeof src === 'object' && target && typeof target === 'object') {
target = target || {};

@@ -160,0 +162,0 @@ Object.keys(src).forEach(function (key) {

{
"name": "trooba-xhr-transport",
"version": "1.0.0",
"version": "2.0.0",
"description": "AJAX/XHR transport for trooba pipeline",

@@ -10,7 +10,8 @@ "main": "index.js",

"scripts": {
"test": "./node_modules/mocha/bin/mocha test"
"test": "./node_modules/mocha/bin/mocha test",
"test-coverage": "./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec"
},
"repository": {
"type": "git",
"url": "git+https://github.com/dimichgh/trooba-xhr-transport.git"
"url": "git+https://github.com/trooba/trooba-xhr-transport.git"
},

@@ -27,5 +28,5 @@ "keywords": [

"bugs": {
"url": "https://github.com/dimichgh/trooba-xhr-transport/issues"
"url": "https://github.com/trooba/trooba-xhr-transport/issues"
},
"homepage": "https://github.com/dimichgh/trooba-xhr-transport#readme",
"homepage": "https://github.com/trooba/trooba-xhr-transport#readme",
"devDependencies": {

@@ -36,2 +37,3 @@ "app-module-path": "^2.1.0",

"express": "^4.14.0",
"istanbul": "^0.4.5",
"lasso": "^2.8.1",

@@ -45,3 +47,3 @@ "lasso-marko": "^2.0.7",

"supertest": "^2.0.1",
"trooba": "^0",
"trooba": "^1",
"zombie": "^5.0.4"

@@ -51,4 +53,4 @@ },

"jsonpipe": "^2.1.1",
"trooba-http-api": "^1"
"trooba-http-api": "^2"
}
}
# trooba-xhr-transport
[![codecov](https://codecov.io/gh/trooba/trooba-xhr-transport/branch/master/graph/badge.svg)](https://codecov.io/gh/trooba/trooba-xhr-transport)
[![Build Status](https://travis-ci.org/trooba/trooba-xhr-transport.svg?branch=master)](https://travis-ci.org/trooba/trooba-xhr-transport) [![NPM](https://img.shields.io/npm/v/trooba.svg)](https://www.npmjs.com/package/trooba)
[![Downloads](https://img.shields.io/npm/dm/trooba.svg)](http://npm-stat.com/charts.html?package=trooba)
[![Known Vulnerabilities](https://snyk.io/test/github/trooba/trooba-xhr-transport/badge.svg)](https://snyk.io/test/github/trooba/trooba-xhr-transport)
XHR transport for trooba pipeline to make CORS RESTful service calls from the browser.
## Get Involved
- **Contributing**: Pull requests are welcome!
- Read [`CONTRIBUTING.md`](.github/CONTRIBUTING.md) and check out our [bite-sized](https://github.com/trooba/trooba-xhr-transport/issues?q=is%3Aissue+is%3Aopen+label%3Adifficulty%3Abite-sized) and [help-wanted](https://github.com/trooba/trooba-xhr-transport/issues?q=is%3Aissue+is%3Aopen+label%3Astatus%3Ahelp-wanted) issues
- Submit github issues for any feature enhancements, bugs or documentation problems
- **Support**: Join our [gitter chat](https://gitter.im/trooba) to ask questions to get support from the maintainers and other Trooba developers
- Questions/comments can also be posted as [github issues](https://github.com/trooba/trooba-xhr-transport/issues)
## Install

@@ -14,5 +27,5 @@

```js
var xhrTransportFactory = require('trooba-xhr-transport');
var xhrTransport = require('trooba-xhr-transport');
require('trooba')
.transport(xhrTransportFactory, {
.use(xhrTransport, {
protocol: 'http:',

@@ -22,3 +35,3 @@ hostname: 'www.google.com'

})
.create()
.build('client:default')
.get({

@@ -32,1 +45,4 @@ q: 'nike'

```
For a real browser example, take a look at [unit test](test/browser.js).
It uses [lasso-js](https://github.com/lasso-js/lasso) and [marko-js](https://github.com/marko-js/marko) to bundle resources into browser page including [trooba xhr implementation](https://github.com/trooba/trooba-xhr-transport/blob/master/test/fixtures/components/app-ajax/index.js#L35).
SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc