Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do i get the configuration defined in application.json and middleware.json? #38

Closed
linhmtran168 opened this issue Nov 29, 2013 · 3 comments

Comments

@linhmtran168
Copy link

Suppose I want to put some custom configurations in app.json or middleware.json.
Currently I can use nconf to get them like this:

var nconf = require('nconf');
var sessionSettings = nconf.get('middleware:session');

But is there a better way to do this?

@tlivings
Copy link
Member

Your configure handler will be passed the configuration loaded from the ./config directory.

Example:

var app = {
    configure: function (config, callback) {
        sessionSettings = config.get('middleware:session');
        callback();
    }
};

See: lifecycle.

@linhmtran168
Copy link
Author

But how can I get the configuration from my controller?

@lmarkus
Copy link
Contributor

lmarkus commented Nov 29, 2013

Using nconf like you would in an express app.
Here's a quick example to get you started: https://github.com/lmarkus/Kraken_Example_Configuration

Take a look at ./index.js for the general configuration and ./controllers/index.js for controller-based configuration.

I'll flesh out the Readme once we're back from the holiday break.

t0lkman pushed a commit to t0lkman/kraken-js that referenced this issue Feb 6, 2014
Add port/socket messaging on startup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants