A node.js based in-memory, URL shortener.
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
public
tests
utils
views
.gitignore
LICENSE
README.md
apikeys.json
app.js
node-modules
shawties.json

README.md

Shawtie

An in-memory URL-shortener written in 100% pure JavaScript à la Node.js.

Installation

Clone the repo, then:

  sh node-modules       # Requires http://github.com/isaacs/npm
  cd shawtie
  node app.js

Usage

node app.js will spin up the shawtie service.

Try a short URL

In your favorite web browser, type:

http://127.0.0.1:3003/s/A

and you'll be redirected to http://subprint.com.

Create a short URL

If you want to add a new short url, open up another terminal and in the same directory type

node ./tests/test.js http://somenewurl.com/long/url.html

Returns the json object response (just sample code here, your shortenedUrl may be different):

{
    "code":201,
    "message":"Long URL added to in memory store.",
    "shortendUrl":"http://127.0.0.1:3003/s/K",
    "longurl":"http://somenewurl.com/long/url.html"
}

or use curl

curl -i -H "Accept: application/json" -X POST -d "longurl=http://somenewurl.com/long/another-url.html" http://127.0.0.1:3003/api/create?apikey=823776525776c8f23a87176c59d25759da7a52c4

You should receive (or something relatively similar):

{
    "code":201,
    "message":"Long URL added to in memory store.",
    "shortendUrl":"http://127.0.0.1:3003/s/L",
    "longurl":"http://somenewurl.com/long/another-url.html"
}

If you use the curl route, you'll need to CHMOD on the app.js file so it can write the in-memory store to a file.

CHMOD 777 app.js

Not a fan of command line interfaces? No worries, navigate to here:

http://127.0.0.1:3003/api/invite

To get your own API key.

Then, head over to:

http://127.0.0.1:3003/api/create

And give it a shot there.

TODO

  • npm installation support
  • CouchDB backup
  • Admin GUI