compoundjs

Compound JS load configuration from DB on startup


I'm trying to use Compound JS and want to load on startup some values from DB and store them in global variables shared across all sessions.

How can I do it?


Solution

  • One way would be to put them in the config/initializers folder.

    Example: /config/initializers/settings.js

    module.exports = function (compound) {
        compound.models.Setting.all(function (err, settings) {
            compound.settings = settings;
        });
    };