Permalink
Browse files

[comments]

  • Loading branch information...
edwardhotchkiss committed Mar 17, 2012
1 parent d7cffb4 commit 3a3ff02e94d1f93aeba98c1bc3f58b54f245ba94
Showing with 40 additions and 32 deletions.
  1. +40 −32 lib/short.js
View
@@ -1,15 +1,15 @@
-/*!
- Core Modules
+/**
+ * Core Modules
*/
var mongoose = require('mongoose')
, ShortURL;
-/*!
- @method hasher
- @param {String} URL URL to be hashed
- @returns {String} hash Base 62 hash representation of the URL
+/**
+ * @method hasher
+ * @param {String} URL URL to be hashed
+ * @returns {String} hash Base 62 hash representation of the URL
*/
var hasher = exports.hasher = function(URL, length) {
@@ -22,9 +22,9 @@ var hasher = exports.hasher = function(URL, length) {
return AUID.join('');
};
-/*!
- @method connect
- @param {String} mongdb Mongo DB String to connect to
+/**
+ * @method connect
+ * @param {String} mongdb Mongo DB String to connect to
*/
var connect = exports.connect = function(mongodb) {
@@ -34,31 +34,38 @@ var connect = exports.connect = function(mongodb) {
createModel();
};
-// This will create a connection, instead of using the global mongo connection.
-exports.createConnection = function createConnection(mongoUri) {
- var connection = exports.connection = mongoose.createConnection(mongoUri, function(err) {
- if(err) {
- console.log('connection error: ' + require('util').inspect(err));
+/**
+ * @expose createConnection
+ * This will create a connection, instead of using the global mongo connection.
+ */
+
+exports.createConnection = function createConnection(MongoURI) {
+ var connection = exports.connection = mongoose.createConnection(MongoURI, function(error) {
+ if (error) {
+ console.log('connection error: ' + require('util').inspect(error));
}
});
-
// Event when the db is connected
- connection.once('open', function () {
- console.log('short package opened connection to mongo db: ' + mongoUri);
+ connection.once('open', function() {
+ console.log('short package opened connection to mongo db: ' + MongoURI);
});
-
createModel();
}
-// Connect after a connection has been declared, it is OK if not connected yet, mongoose handles that
+/**
+ * @method createModel
+ * Connect after a connection has been declared
+ * it is OK if not connected yet, mongoose buffers request
+ */
+
function createModel() {
ShortURL = exports.ShortURL = require('../models/ShortURL');
}
-/*!
- @method generate
- @param {String} URL URL to create a Short URL of
- @param {Functon} callback Callback to execute on completion
+/**
+ * @method generate
+ * @param {String} URL URL to create a Short URL of
+ * @param {Functon} callback Callback to execute on completion
*/
var generate = exports.generate = function(URL, options, callback) {
@@ -94,10 +101,10 @@ var generate = exports.generate = function(URL, options, callback) {
});
}
-/*!
- @method retrieve
- @param {String} hash Hashed Base 62 URL to retrieve
- @param {Functon} callback Callback to execute on completion
+/**
+ * @method retrieve
+ * @param {String} hash Hashed Base 62 URL to retrieve
+ * @param {Functon} callback Callback to execute on completion
*/
var retrieve = exports.retrieve = function(hash, options, callback) {
@@ -121,10 +128,10 @@ var retrieve = exports.retrieve = function(hash, options, callback) {
});
};
-/*!
- @method list
- @param {Function} callback
- List all Shortened URLs
+/**
+ * @method list
+ * @param {Function} callback
+ * List all Shortened URLs
*/
var list = exports.list = function(callback) {
@@ -135,5 +142,6 @@ var list = exports.list = function(callback) {
callback(null, urls);
}
});
-}
+};
+
/* EOF */

0 comments on commit 3a3ff02

Please sign in to comment.