From 636c439eff7bfcecd96480bdae0a6351aa0ea096 Mon Sep 17 00:00:00 2001 From: Levi Olson Date: Mon, 4 Jan 2016 11:48:16 -0600 Subject: [PATCH] Updating package.json to reflect github location; improving database.js; and minor tweaks to app.js method variable --- app.js | 9 ++++++--- database.js | 2 +- package.json | 10 +++++----- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app.js b/app.js index b23584c..ccde2da 100644 --- a/app.js +++ b/app.js @@ -34,9 +34,11 @@ app.all('*', function(req, res, next) { console.log(req.body._method); console.log(url); console.log(req.path); + + var method = req.body._method || req.method; request( { - method : req.body._method || req.method, + method : method, uri : url + req.path, multipart : [{ 'content-type' : 'application/json', @@ -46,10 +48,11 @@ app.all('*', function(req, res, next) { function(error, response, body) { if (!error && response.statusCode == 200) { var request = { + "ok" : response.statusCode==200?true:false, "baseUrl" : url, "body" : req.body, - "method" : req.method, - "requestParams" : req.body.params, + "method" : method, + "ProxyRequest" : req.body.params, "originalUrl" : req.originalUrl, "path" : req.path, "protocol" : req.protocol, diff --git a/database.js b/database.js index 6d5df3b..5dad9b4 100644 --- a/database.js +++ b/database.js @@ -12,7 +12,7 @@ module.exports.DatabaseLookup = function(req, done) { connection.connect(function(err) { if (err) done(err); }); - connection.query('SELECT password FROM users WHERE email = \''+req.body.email+'\'', function(err, result, fields) { + connection.query(mysql.format('SELECT password FROM users WHERE email = ?', [req.body.email]), function(err, result, fields) { if (err) done(err); if (!result || !result[0] || !result[0].password) return done(null, false); diff --git a/package.json b/package.json index 9ca4cb5..06cbe09 100644 --- a/package.json +++ b/package.json @@ -1,18 +1,18 @@ { "name": "Guardian", "version": "0.0.1", - "description": "Proof-of-concept for the guardian service.", + "description": "A single proxy server to authenticate requests to multiple internal APIs", "main": "app.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { "type": "git", - "url": "git+ssh://git@bitbucket.org/leothelocust/guardian-node.git" + "url": "git@github.com:leothelocust/guardian-api-proxy.git" }, - "author": "Levi Olson ", - "license": "UNLICENSED", - "homepage": "https://bitbucket.org/leothelocust/guardian-node#readme", + "author": "Levi Olson on GitHub", + "license": "MIT License", + "homepage": "https://github.com/leothelocust/guardian-api-proxy", "dependencies": { "bcrypt": "^0.8.5", "body-parser": "^1.14.2",