Skip to content

Commit

Permalink
Added database connectivity library
Browse files Browse the repository at this point in the history
Added mongoose dependency
  • Loading branch information
lmarkus committed Dec 4, 2013
1 parent 9df01dd commit b071b53
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 31 deletions.
25 changes: 25 additions & 0 deletions lib/database.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* A custom library to establish a database connection
*/
'use strict';
var mongoose = require('mongoose');

var db = function () {
return {

/**
* Open a connection to the database
* @param conf
*/
config: function (conf) {
mongoose.connect('mongodb://' + conf.host + '/' + conf.database);
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function callback() {
console.log('db connection open');
});
}
};
};

module.exports = db();
63 changes: 32 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
{
"name": "kraken-example-shopping-cart",
"version": "0.0.1",
"description": "A non-trivial kraken app",
"author": "@LennyMarkus",
"main": "index.js",
"scripts": {
"test": "grunt test",
"start": "node index.js"
},
"engines": {
"node": ">=0.10.0"
},
"dependencies": {
"kraken-js": "~0.6.1",
"express": "~3.4.4",
"adaro": "~0.1.x",
"nconf": "~0.6.8",
"less": "~1.3.3",
"dustjs-linkedin": "~2.0.3",
"dustjs-helpers": "~1.1.1",
"makara": "~0.3.0"
},
"devDependencies": {
"mocha": "~1.10.0",
"grunt": "~0.4.1",
"grunt-contrib-less": "~0.7.0",
"grunt-dustjs": "~1.1.1",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-jshint": "~0.6.4",
"grunt-mocha-cli": "~1.3.0"
}
"name": "kraken-example-shopping-cart",
"version": "0.0.1",
"description": "A non-trivial kraken app",
"author": "@LennyMarkus",
"main": "index.js",
"scripts": {
"test": "grunt test",
"start": "node index.js"
},
"engines": {
"node": ">=0.10.0"
},
"dependencies": {
"kraken-js": "~0.6.1",
"express": "~3.4.4",
"adaro": "~0.1.x",
"nconf": "~0.6.8",
"less": "~1.3.3",
"dustjs-linkedin": "~2.0.3",
"dustjs-helpers": "~1.1.1",
"makara": "~0.3.0",
"mongoose": "~3.8.1"
},
"devDependencies": {
"mocha": "~1.10.0",
"grunt": "~0.4.1",
"grunt-contrib-less": "~0.7.0",
"grunt-dustjs": "~1.1.1",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-jshint": "~0.6.4",
"grunt-mocha-cli": "~1.3.0"
}
}

0 comments on commit b071b53

Please sign in to comment.