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

bfg

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bfg - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

2

package.json
{
"name": "bfg",
"version": "0.1.0",
"version": "0.2.0",
"description": "Big Friendly Gateway creates a read and write stream to various cloud storage providers",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -86,2 +86,3 @@ bfg

-c, --container [value] Rackspace Container
-f, --folder [value] Rackspace Folder
-V, --version output the version number

@@ -96,2 +97,4 @@ ```

* RACKSPACE_CONTAINER
* RACKSPACE_FOLDER
* RACKSPACE_CDN

@@ -155,2 +158,20 @@ Assuming the environment variables are set - here is an example of streaming a local file to rackspace:

## CDN
You can instruct bfg to redirect GET requests to the CDN for the container.
First you must pass the cdn option when you make a disk.
Second pass true to the handler function to get a handler that will redirect rather than stream directly:
```js
var disk = bfg.rackspace({
username:...,
etc:...,
cdn:'https://bf9164d97a0cd15823f4-4dba8edb0fc2b3e5cc0f769b1eea32ba.ssl.cf3.rackcdn.com'
})
app.use('/filestore', disk.handler(true));
```
## var folder = disk.folder(basepath)

@@ -172,2 +193,3 @@

## events

@@ -174,0 +196,0 @@

@@ -5,7 +5,10 @@ var EventEmitter = require('events').EventEmitter;

function Disk(driver, container, folder){
function Disk(driver, options){
EventEmitter.call(this);
this._driver = driver;
this._container = container;
this._folder = folder || '';
options = options || {}
this._options = options;
this._container = options.container;
this._folder = options.folder || '';
}

@@ -18,3 +21,5 @@

Disk.prototype.folder = function(basepath){
return new Disk(this._driver, this._container, basepath);
var newoptions = JSON.parse(JSON.stringify(this._options));
newoptions.folder = basepath;
return new Disk(this._driver, newoptions);
}

@@ -64,4 +69,8 @@

Disk.prototype.handler = function(){
Disk.prototype.handler = function(cdn){
var self = this;
if(cdn && !this._options.cdn){
throw new Error('cdn option required for CDN redirects');
}
return function(req, res){

@@ -84,12 +93,21 @@ if(req.method=='POST'){

else{
var remote = self.createReadStream(req.url);
if(cdn){
res.writeHead(302, {
'Location': this._options.cdn + req.url
});
res.end();
}
else{
var remote = self.createReadStream(req.url);
remote.on('error', function(error){
res.statusCode = 500;
res.end(error.toString())
})
remote.on('error', function(error){
res.statusCode = 500;
res.end(error.toString())
})
remote.pipe(res);
remote.pipe(res);
}
}
}
}

@@ -8,4 +8,4 @@ var Disk = require('./disk');

var driver = Rackspace(options);
return new Disk(driver, options.container, options.folder);
return new Disk(driver, options);
}
}

@@ -1,1 +0,1 @@

hello world 1394993440236
hello world 1394994239026

@@ -1,1 +0,1 @@

hello world 1394993440236
hello world 1394994239026
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