I am creating a node.js application that will upload files to my S3 bucket using knox. I can interact with S3 as expected, but I would like my controller to get the configuration so that I can dynamically build my client with the settings.
My questions are: how do I get configuration settings down the call stack to my controller without fear?
Disclaimer: I'm pretty new to node.js, so it could just be a lack of knowledge about the difference between exports. and module.exports. *
Here is an example of how interaction works with my code:
app.js
...
config = require('./config/config')['env'];
require('./config/router')(app, config);
...
router.js
module.exports = function(app, config) {
...
var controller = require('../app/controllers/home');
app.post('/upload', controller.upload);
...
}
home.js
var knox = require('knox');
var client = knox.createClient({ ... });
...
exports.upload = function(req, res) {
}
...
Benny source
share