Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions lib/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand All @@ -150,7 +156,7 @@ var delegate = function (apicall, opts, req, res) {

return callback(err, data);

});
}, ctx);

}

Expand Down Expand Up @@ -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);

}

Expand Down Expand Up @@ -221,4 +227,4 @@ module.exports = {
parseRequest: parseRequest,
getAuthentication: getAuthentication,
combineWithAuthentication: combineWithAuthentication
}
}
1 change: 1 addition & 0 deletions restly.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down