Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9202339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:14:00+00:00 2026-06-17T23:14:00+00:00

I am building a node.js app that will upload files to my S3 bucket

  • 0

I am building a node.js app that will upload files to my S3 bucket using knox. I am able to interact with S3 as expected, but I would like to make my controller to receive configuration so I can dynamically construct my client with configuration values.

My questions is how do I get configuration paramters down the call stack to my controller without being careless?

Disclaimer: I am rather new to Node.js so it could be simply my lack of knowledge in the difference between exports. and module.exports.*

Here is an example of how the 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'); //Is there a way for me to pass config here?
  app.post('/upload', controller.upload); //Or here?
...
}

home.js

var knox = require('knox');

var client = knox.createClient({ ... }); //I want to use config.key, config.secret, etc instead of hard-coded values
...
exports.upload = function(req, res) {
  //Use client
}
...
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T23:14:01+00:00Added an answer on June 17, 2026 at 11:14 pm

    Try doing something like this…

    var config = require('./config/config')['env'];
    
    // The use function will be called before your 
    //  action, because it is registered first.
    app.use(function (req, res, next) {
    
      // Assign the config to the req object
      req.config = config;
    
      // Call the next function in the pipeline (your controller actions).
      return next();
    
    });
    
    // After app.use you register your controller action
    app.post('/upload', controller.upload); 
    

    And then in your controller action…

    exports.upload = function(req, res) {
    
      //Your config should be here...
      console.log(req.config);
    
    }
    

    Ps. I can not try it right now, but I solved a similar issue like this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building a small app that uses backbone.js on the client side, node.js/socket.io
I'm building an app in Backbone using Node as the backend. As part of
I am building an ASP.NET web application that will be deployed to a 4-node
I'm building a system in Node.js that is supposed to find all files in
I am building a todo app using express framework on node server...I have an
I am building an app on node.js using express, and node-mysql driver. There is
Im building an upload tool using node.js and socket.io , because they usually upload
I'm building a new web app. It will be in Django, but I'm now
I am building a website/app using node.js, express and nowjs. Once user log into
I have a Node.js app that I'm building and deploying to Cloud Foundry. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.