Skip to content
This repository

A node.js based in-memory, URL shortener.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 public
Octocat-spinner-32 tests
Octocat-spinner-32 utils Removed some console.log and forced true on valid url. October 31, 2010
Octocat-spinner-32 views
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 apikeys.json
Octocat-spinner-32 app.js
Octocat-spinner-32 node-modules
Octocat-spinner-32 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
Something went wrong with that request. Please try again.