Compound JS load configuration from DB on startup

140 Views Asked by At

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?

1

There are 1 best solutions below

0
On BEST ANSWER

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;
    });
};