A LevelDB backed URL unshortening microservice written in JavaScript
Switch branches/tags
Nothing to show
Clone or download
Latest commit 4a75418 Oct 29, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
commands subcommands Oct 28, 2018
.dockerignore Added Dockerfile and related tweaks Feb 3, 2015
.gitignore subcommands Oct 28, 2018
.travis.yml coffee not needed Jun 19, 2017
Dockerfile updated Oct 28, 2018
LICENSE updated license Jun 14, 2017
Makefile moved to docnow dockerhub Dec 1, 2017
README.md subcommands Oct 28, 2018
index.js some deps are in metaweb now Oct 29, 2018
package-lock.json audit fix Oct 29, 2018
package.json some deps are in metaweb now Oct 29, 2018
test.js subcommands Oct 28, 2018



Build Status

unshrtn is a LevelDB backed URL unshortening microservice written in JavaScript and Node for quick, asynchronous processing of requests. unshrtn remembers what it has already looked up so it can save you the trouble of keeping track of URLs when you are looking up a lot of them at one time and they haven't necessarily been de-duplicated.

unshrtn uses the metaweb library to do the lookups, which means that in addition to returning the unshortened URL you will also get some potentially useful metadata if the response happens to be HTML:

% curl http://localhost:3000?url=https://bitly.com/4kb77v
  "short": "https://bitly.com/4kb77v",
  "long": "https://www.youtube.com/watch?v=oHg5SJYRHA0",
  "canonical": "https://www.youtube.com/watch?v=oHg5SJYRHA0",
  "status": 200,
  "content_type": "text/html; charset=utf-8",
  "title": "RickRoll'D - YouTube",
  "description": "http://www.facebook.com/rickroll548 As long as trolls are still trolling, the Rick will never stop rolling.",
  "image": "https://i.ytimg.com/vi/oHg5SJYRHA0/hqdefault.jpg",
  "publisher": "YouTube",
  "keywords": ["Cotter548", "Shawn", "Cotter", "lol", "gamefaqs", "CE", "reddit", "rettocs", "no", "brb", "afk", "lawl", "pwnt", "Rickroll", "Rickroll'd", "Rick", "Roll", "Duckroll", "Duck", "rick", "roll", "astley", "..."]


Probably the easiest way to get unshrtn up and running is with Docker.

docker run -p 3000:3000 docnow/unshrtn

You can also install it with npm:

% npm install -g unshrtn


Once installed you can start up the microservice:

% unshrtn start

If you'd like more control over how it starts use the start subcommand:

% unshrtn start --host --port 8080 --log /var/log/unshrtn.log

By default unshrtn writes its database to unshrtn.db in the current working directory. However you can control this with the --database option:

% unshrt start --database /var/unshrtn/unshrtn.db

You can dump the database as line oriented JSON and load it againif you want to back it up or move it around:

% unshrtn dump /path/to/datbase > backup.jsonl
% cat backup.jsonl | unshrtn load /path/to/another/database

If you just want to look up one URL you can also use unshrtn on the command line:

% unshrtn get https://bitly.com/4kb77v