I am using express and setting up a module to handle the requests to a third party API. The third party requires a ID and key to be passed over. I would rather not hard code the key and ID in the module but allow the server to pass it over to the module simply because it will allow more flexibility in the future. Here is what I have
//app.js
var express = require('express');
var app = express();
var ghost = require('./ghost.js');
app.get('/v1/ghost.json', ghost.list_all);
//ghost.js module
exports.list_all = function (req, res) {
//THE ID AND KEY I WNAT O PASS OVER FROM app.js??????
foo.byUnique(id, key, function(error, resource) {
send_success(res, resource);
});
};
function send_success(res, data) {
//stuff
var output = {data: data };
res.end(JSON.stringify(output) + "\n");
}
// i do not want to hard code into the module the id and key as such
var id = 'myid';
var key = 'mykey';