Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including shortness with all npm packages installed. Try it out:

var shortness = require("shortness")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

shortness v0.0.2

Node based URL shortener that uses SQLite

NAME

shortness

EXAMPLE

var shortness = require('shortness')
  ;

// Adding!
shortness.add('http://some-long-address.tld/with/some/more/longness', function(shortId) {
  console.log('new url: http://short.tld/' + shortId);
  // output: "new url: http://short.tld/t8j30vns"
});

// Retreiving!
shortness.get('t8j30vns', function(targetUrl) {
  console.log('real url: ', targetURL);
  // output: "real url: http://some-long-address.tld/with/some/more/longness"
});

NOTES

This is really just a very thin wrapper around sqlite3. It doesn't do any validation. You will need to do your own HTTP (or whatever protocol suits your fancy) stuff around this module. Really, it's just a glorified key value store.

Available through npm: npm install shortness

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free