Skip to content

joemckie/buffer-node

Repository files navigation

Buffer for Node

Build Status Coverage Status npm version Gitter

NPM

Getting started:

Installation

To get started with this package, install it with npm i buffer-node-api --save.

Usage

For simplicity, examples will be shown using the ES5 syntax.

Express

In a real world situation, you should save the client in the user's session, and not overwrite the client variable on the server.

var BufferClient = require('buffer-node-api'),
    app          = require('express')(),
    client       = null;
  
// Returning from the OAuth gateway
app.get('/verify', function (req, res) {
  client = new BufferClient({
    access_token: req.query.code,
    client_id: '<your_client_id>',
    client_secret: '<your_client_secret>',
    redirect_url: '<your_redirect_url>',
    authenticated: false
  }, function (err, result) {
    if (!err) {
      // Client instantiated correctly, you should redirect away from this page
    }
  });
});

app.get('/login', function (req, res) {
  var auth_url = BufferClient.getAuthorizationUrl('<your_client_id>', '<your_redirect_url>');
  
  // Use auth_url somewhere on your page to link to Buffer's authorisation gateway page
});

app.get('/deauthorize', function (req, res) {
  client.deauthorizeUser(function (err, result) {
    if (!err) {
      // User deauthorised. Redirect away
    }
  });
});

Documentation

For full code documentation and examples, click here.

Licence:

This package is released under the MIT Licence. This means you're free to use it at no cost in any of your commercial or non-commercial projects. If you want to contribute to this project, great! Please read below for instructions on how to get involved.

Contributing:

Getting started is easy with the Vagrant VM. Simply run vagrant up and then vagrant ssh. There is currently a bug in the Chef provisioning preventing the Vagrant instance from starting. Looking into it and will apply a fix ASAP. For now, please ignore this step.

Please follow the following guidelines when writing new code:

  1. Nobody likes being wet. Stay DRY.
  2. Follow the Boy Scout Rule. Litterers will be punished!
  3. All source code is written in ES6 and transpiled with Babel. No ES5 code, please!
  4. Test your code with the npm test command and check for coverage using npm run coverage. If possible, aim for 100% coverage - the Travis/Coveralls build process will fail if the overall value falls below 80%.
  5. Don't be this guy. Meaningless commit messages make me sad :(

About

NodeJS API wrapper for Buffer.com

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published