Socket
Socket
Sign inDemoInstall

chauncey

Package Overview
Dependencies
18
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    chauncey

Shorten URLs with bitly.


Version published
Maintainers
1
Install size
1.56 MB
Created

Readme

Source

chauncey

NPM version Dependency status

Shorten URLs with Bitly.

Usage: chauncey <url> [options]

Options:
  -h, --help  Show help

Example:
  chauncey http://google.com/  Shorten http://google.com/ using Bitly

"Chauncey"?

Chauncey McPufferson is Bitly's mascot :smiley:

Installation

$ npm i -g chauncey

Configuration

First you need a Bitly developer access token. Then you'll need to add the token to your user environment, for example:

$ BITLY_ACCESS_TOKEN=[access token] chauncey http://google.com/

You can also use a .chaunceyrc file. Chauncey will look for .chaunceyrc starting in process.cwd(), then ../, ../../, all the way up to the filesystem root. It should have the following content:

export BITLY_ACCESS_TOKEN=[access token]

Usage

Chauncey will output the shortened URL to stdout:

$ chauncey http://google.com/
http://bit.ly/1jib0Hi

So on OS X, you can do stuff like:

$ chauncey http://google.com/ | pbcopy

API

TODO: what if someone

chauncey(url, [token], [callback])

Shortens url using the Bitly API.

Arguments

  • url - The URL to shorten.
  • token - Optional Bitly developer access token. If not passed, chauncey will look for token as described in configuration.
  • callback - Optional
  • callback(err, results) - Optional A callback which is called after all the iterator functions have finished, or an error occurs. Results is an array containing the concatenated results of the iterator function.

Note: the callbacks do not take an error as their first argument.

Example

async.every(['file1','file2','file3'], fs.exists, function(result){
    // if result is true then every file exists
});

export default ({ url, token, done = () => {} }) => {

try { token = token || findToken(); } catch (error) { return done(error); }

https.get( https://api-ssl.bitly.com/v3/shorten?access_token=${token}&longUrl=${url}&format=txt, (res) => res.pipe(concat({ encoding: 'string' }, (res) => done(null, res))) ).on('error', done);

};

function findToken() { habitat.load(findNearest('.chaunceyrc')); const token = habitat.get('BITLY_ACCESS_TOKEN'); if (!token) throw new Error('BITLY_ACCESS_TOKEN not found'); return token; }

Note

This module uses the Bitly API, but is neither developed nor endorsed by Bitly.

License

MIT

Keywords

FAQs

Last updated on 14 Oct 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc