diff --git a/lib/routes.js b/lib/routes.js index 5d483d2..3e2f7e2 100644 --- a/lib/routes.js +++ b/lib/routes.js @@ -140,6 +140,12 @@ var delegate = function (apicall, opts, req, res) { // load the library var lib = require(apicall.library); + // prepare the context for req / res + var ctx = { + req: req, + res: res + } + // call the callback lib[apicall.callback](opts, function(err, data) { @@ -150,7 +156,7 @@ var delegate = function (apicall, opts, req, res) { return callback(err, data); - }); + }, ctx); } @@ -180,7 +186,7 @@ var delegate = function (apicall, opts, req, res) { sendResponse.data = result.request; } - return res.status(404),send(sendResponse); + return res.status(404).send(sendResponse); } @@ -221,4 +227,4 @@ module.exports = { parseRequest: parseRequest, getAuthentication: getAuthentication, combineWithAuthentication: combineWithAuthentication -} \ No newline at end of file +} diff --git a/restly.js b/restly.js index 4b2f586..9c51e53 100644 --- a/restly.js +++ b/restly.js @@ -19,6 +19,7 @@ var app = express(); // force express to parse posted and putted parameters app.use(bodyParser.urlencoded({ extended: true, uploadDir: '/tmp' })); +app.use(bodyParser.json()); // define public directory for docs app.use(express.static(__dirname+'/public'));