Minimal short link system for
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Build Status

Minimal short link system for

Simple url shortener on json base that matches short keys to urls and keeps track of the number of clicks including a small social suffix feature to differentiate the platform the link was clicked on.


Link is the main class of the project. You can lookup urls and create new keys:


You can lookup a given key with optional source platform. If the key is unknown the method returns false.

const link = require('./lib/Link').getInstance();

const url = link.lookup('MY_KEY');


If you want to add another url to the system you can do this with store, that requires the url that should be shortened. The default length of generated keys is currently 5 characters. You can change that with the second parameter keyLength.

const key ='');

If the given url exists in the system already, you will of course get the current key for the url!


At the moment there are a few routes that define the basic needs of the system.

  • lookup is used to get the url for a given short key and redirects the client to the link destination.
  • add can add a new short key with the information of the url that should be shortened and the secret token as defined in the config. The parameter have to be sent in the POST body of the request.
  • error400 and error404 are default JSON responses that notify the user that the link could not be added or the key was not found.

Database support

Currently the system comes without database support but can be added via an adapter in future releases. The current version uses a simple links.json file in the ./data directory.