Comparing version 0.0.2 to 0.0.3
@@ -49,3 +49,3 @@ ## Node Box SDK | ||
### Running with Passport authentication under Express | ||
**Note:** For a complete express example, look under `test/helpers/express`. | ||
**Note:** There is a complete express example in [this gist](https://gist.github.com/adityamukho/13c7c462e216fa02d0a9). | ||
``` | ||
@@ -84,2 +84,23 @@ var express = require('express'), | ||
}); | ||
app.get('/', function (req, res) { | ||
var opts = { | ||
user: req.user | ||
}; | ||
if (req.user) { | ||
var connection = box.getConnection(req.user.login); | ||
connection.ready(function () { | ||
connection.getFolderItems(0, null, function (err, result) { | ||
if (err) { | ||
opts.body = err; | ||
} else { | ||
opts.body = result; | ||
} | ||
res.render('index', opts); | ||
}); | ||
}); | ||
} else { | ||
res.render('index', opts); | ||
} | ||
}); | ||
``` | ||
@@ -86,0 +107,0 @@ |
@@ -90,2 +90,3 @@ 'use strict'; | ||
* @param {optionalErrorCallback} done - Called after finishing one round of long polling. | ||
* @fires Connection#"polling.ready" | ||
*/ | ||
@@ -110,2 +111,7 @@ _longPoll: function (done) { | ||
self.nsp = body.next_stream_position; | ||
/** | ||
* Fires when a stream position has been fixed. All events from here onwards will be captured. | ||
* @event Connection#"polling.ready" | ||
*/ | ||
self.emit('polling.ready'); | ||
} | ||
@@ -112,0 +118,0 @@ self._request('https://api.box.com/2.0/events', 'OPTIONS', next); |
@@ -130,5 +130,6 @@ 'use strict'; | ||
* @param {requestCallback} done - The callback to invoke (with possible errors) when the request returns. | ||
* @param {?RequestHeaders} [headers] - Additional headers. | ||
* @param {?RequestConfig} [config] - Configure the request behaviour. | ||
*/ | ||
uploadFile: function (name, parent_id, opts, done, config) { | ||
uploadFile: function (name, parent_id, opts, done, headers, config) { | ||
if (!_.isString(name) || !_.isNumber(parseInt(parent_id, 10))) { | ||
@@ -142,3 +143,3 @@ return done(new Error('Invalid params. Required - name: string, parent_id: number')); | ||
var data = fs.createReadStream(name); | ||
this._request(['files', 'content'], 'POST', done, null, opts, data, null, null, config); | ||
this._request(['files', 'content'], 'POST', done, null, opts, data, headers, null, config); | ||
}, | ||
@@ -145,0 +146,0 @@ |
{ | ||
"name": "box-sdk", | ||
"description": "Node.js client for Box Content API", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"homepage": "https://github.com/adityamukho/node-box-sdk", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -50,3 +50,3 @@ # Node Box SDK [![Build Status](https://travis-ci.org/adityamukho/node-box-sdk.svg?branch=master)](https://travis-ci.org/adityamukho/node-box-sdk) | ||
### Running with Passport authentication under Express | ||
**Note:** For a complete express example, look under `test/helpers/express`. | ||
**Note:** There is a complete express example in [this gist](https://gist.github.com/adityamukho/13c7c462e216fa02d0a9). | ||
```javascript | ||
@@ -85,2 +85,23 @@ var express = require('express'), | ||
}); | ||
app.get('/', function (req, res) { | ||
var opts = { | ||
user: req.user | ||
}; | ||
if (req.user) { | ||
var connection = box.getConnection(req.user.login); | ||
connection.ready(function () { | ||
connection.getFolderItems(0, null, function (err, result) { | ||
if (err) { | ||
opts.body = err; | ||
} else { | ||
opts.body = result; | ||
} | ||
res.render('index', opts); | ||
}); | ||
}); | ||
} else { | ||
res.render('index', opts); | ||
} | ||
}); | ||
``` | ||
@@ -87,0 +108,0 @@ |
'use strict'; | ||
var assert = require("assert"), | ||
_ = require('lodash'), | ||
cp = require('child_process'), | ||
@@ -6,0 +5,0 @@ crypto = require('crypto'), |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
729576
16708
176
3