Skip to content

Latest commit

 

History

History
48 lines (32 loc) · 707 Bytes

README.rst

File metadata and controls

48 lines (32 loc) · 707 Bytes

Low-Fat URL Shortening for Node.js

Requirements:

  • node.js
  • redis

Installation

cd /path/to/shrtn
npm install

or with NPM:

npm install shrtn

Usage

var redis = require('redis');
var shrtn = require('shrtn');

shrtn.config.set('redis client', redis.createClient());

var id;

// shortening
shrtn.shorten('http://google.com', function(response){
  if(response.status === 'OK'){
    id = response.id;
    console.log(response.long + ' -> ' + response.id);
  }
});

// expanding
shrtn.expand(id, function(response){
  if (response.status === 'OK'){
    console.log(id + ' -> ' + response);
  }
});