Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

40 lines (31 sloc) 0.649 kB

short

Node.js Tiny URL generator with analytics

Setup

$ npm install short

Integrated

var mongoose = require("mongoose");
var short = require("short");

mongoose.connect("mongodb://localhost/short");

var URL = "http://nodejs.org/";

short.make(URL, function(error, shortURL) {
    if (error) {
        console.error(error);
    } else {
        short.get(shortURL.hash, function(error, shortURLObject) {
            if (error) {
                console.error(error);
            } else {
                var URL = shortURLObject[0].URL
                var hash = shortURLObject[0].hash;
                console.log(URL, hash);
                process.exit(1);
            }
        });
    }
});

/* EOF */
Jump to Line
Something went wrong with that request. Please try again.