changed to cloudant
This commit is contained in:
parent
2f2a736f46
commit
958e544024
@ -12,6 +12,7 @@
|
|||||||
"basic-authentication": "^1.6.2",
|
"basic-authentication": "^1.6.2",
|
||||||
"body-parser": "^1.15.0",
|
"body-parser": "^1.15.0",
|
||||||
"cheerio": "^0.20.0",
|
"cheerio": "^0.20.0",
|
||||||
|
"cloudant": "^1.6.2",
|
||||||
"cookie-parser": "^1.4.1",
|
"cookie-parser": "^1.4.1",
|
||||||
"ejs": "^2.4.1",
|
"ejs": "^2.4.1",
|
||||||
"express": "^4.13.4",
|
"express": "^4.13.4",
|
||||||
|
@ -23,19 +23,28 @@ var authOptions = {
|
|||||||
var authentication =require('basic-authentication')(authOptions);
|
var authentication =require('basic-authentication')(authOptions);
|
||||||
|
|
||||||
|
|
||||||
var nano = require('nano')('http://martind2000:1V3D4m526i@localhost:5984');
|
|
||||||
var busEmitter = new EventEmitter();
|
var busEmitter = new EventEmitter();
|
||||||
|
|
||||||
var db_name = 'logger';
|
var credentials = {
|
||||||
var dbCouch = nano.use(db_name);
|
"username": "25f854ee-1b51-49ff-acd9-5b0ff478d944-bluemix",
|
||||||
|
"password": "8e417af1b0462ca55726848846cc6b8696fc76defe9d1864cbc334be59549e0c",
|
||||||
|
"host": "25f854ee-1b51-49ff-acd9-5b0ff478d944-bluemix.cloudant.com",
|
||||||
|
"port": 443,
|
||||||
|
"url": "https://25f854ee-1b51-49ff-acd9-5b0ff478d944-bluemix:8e417af1b0462ca55726848846cc6b8696fc76defe9d1864cbc334be59549e0c@25f854ee-1b51-49ff-acd9-5b0ff478d944-bluemix.cloudant.com",
|
||||||
|
"database" : "logger"
|
||||||
|
};
|
||||||
|
|
||||||
|
var Cloudant = require('cloudant');
|
||||||
|
var cloudant = Cloudant({account:credentials.username, password:credentials.password});
|
||||||
|
|
||||||
|
var dbCloudant = cloudant.db.use(credentials.database);
|
||||||
|
|
||||||
function insertLog(obj) {
|
function insertLog(obj) {
|
||||||
logger.debug('Inserting into couch...');
|
logger.debug('Inserting into couch...');
|
||||||
logger.info(util.inspect(obj));
|
logger.info(util.inspect(obj));
|
||||||
var newObj = {body:obj};
|
var newObj = {body:obj};
|
||||||
dbCouch.insert(newObj, function(err, body,header) {
|
dbCloudant.insert(newObj, function(err, body,header) {
|
||||||
if (err) {
|
if (err) {
|
||||||
logger.error('Error inserting into couch');
|
logger.error('Error inserting into couch');
|
||||||
return;
|
return;
|
||||||
@ -57,7 +66,7 @@ busEmitter.on('saveLog', doInsertLog);
|
|||||||
router.get('/', authentication, function (req, res) {
|
router.get('/', authentication, function (req, res) {
|
||||||
logger.debug('list..');
|
logger.debug('list..');
|
||||||
|
|
||||||
dbCouch.view('body','body',function(err, body) {
|
dbCloudant.view('body','body',function(err, body) {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
|
|
||||||
var outJSON = [];
|
var outJSON = [];
|
||||||
@ -86,7 +95,7 @@ router.get('/entry/:id', function (req, res) {
|
|||||||
|
|
||||||
logger.debug(req.params.id);
|
logger.debug(req.params.id);
|
||||||
|
|
||||||
dbCouch.get(req.params.id,function(err, body) {
|
dbCloudant.get(req.params.id,function(err, body) {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
|
|
||||||
var outJSON = {};
|
var outJSON = {};
|
||||||
|
Loading…
Reference in New Issue
Block a user