Wondering what’s next for npm?Check out our public roadmap! »

    config-dynamic

    3.4.4 • Public • Published

    Node-config with dynamic configuration

    You don't have to restart your Node.js app to apply new configuration. Simply update the configuration files. This repository is forked from lorenwest/node-config and more specifically this Pull Request.

    Quick Start

    Install in your app directory, and edit the default config file.

    $ npm install config-dynamic
    $ mkdir config
    $ vi config/default.json
    {
      // Customer module configs
      "foo": {
        "bar": "fizz"
      }
    }

    Example express server that returns the config value:

    $ npm install express
    $ touch index.js
    const config = require('config')
    const express = require('express')
    const app = express()
    const port = 3000
     
    app.get('/', (req, res) => {
      const dbConfig = config.get('foo.bar')
      console.log(dbConfig) // Display the updated configuration
      res.send(dbConfig)
    })
     
    app.listen(port, () => {
      console.log(`Example app listening at http://localhost:${port}`)
    })

    Start your app server:

    $ node index.js
    Example app listening at http://localhost:3000

    Poll the server for the latest configuration:

    $ curl localhost:3000
    fizz

    Update config/default.json.

    {
      // Customer module configs
      "foo": {
        "bar": "buzz"
      }
    }

    Poll the server for the latest configuration:

    $ curl localhost:3000
    buzz

    License

    May be freely distributed under the MIT license.

    Install

    npm i config-dynamic

    DownloadsWeekly Downloads

    0

    Version

    3.4.4

    License

    MIT

    Unpacked Size

    83 kB

    Total Files

    9

    Last publish

    Collaborators

    • avatar