Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    shared-configpublic

    shared-config

    Configuration shared by browser and server.

    Installation

    Using npm:

    npm install shared-config

    Using component:

    component install shared-config

    Usage

    Configuration files are loaded from config/ in your application directory, or from process.env.NODE_CONFIG_PATH if set.

    Configuration files can be json, yaml, or modules. config/default.ext is loaded first, extended with config/<process.env.NODE_ENV>.ext if it exists, and finally extended with config/local.ext if it exists.

    Require the configuration on your server and then send to the client by setting the config cookie.

    config/default.yaml:

    api:
      url: 'https://api.example.com'

    Server:

    var config = require('shared-config');
     
    app
      .use(express.static('./public'))
      .get('/', function(req, res, next) {
        res.cookie('config', config);
        res.render('template', locals);
      });

    Browser:

    var config = require('shared-config');
     
    console.log(config.api);
    // => { url: 'https://api.example.com' } 

    MIT Licensed

    install

    npm i shared-config

    Downloadslast 7 days

    1

    version

    0.3.2

    license

    MIT

    last publish

    collaborators

    • avatar