Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A node.js based in-memory, URL shortener.
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
public Added ignore file. Cleaned up the styling a bit.
tests Fixed double submit issue. Reorg'd dir structure. Added support for w…
utils Removed some console.log and forced true on valid url.
views Added GUI for shortening a link. Added loading of apikeys file from d…
.gitignore Added ignore file. Cleaned up the styling a bit.
LICENSE Adding Sign Up for API key.
README.md Updated README to show non-CLI folks how to use the GUI to get stewey.
apikeys.json
app.js Added ignore file. Cleaned up the styling a bit.
node-modules Removing hashlib after building.
shawties.json Update README and now check for a 'valid' url before shortening.

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.