# All files / server/src/config index.js

100% Statements 8/8
75% Branches 3/4
100% Functions 2/2
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    1928x
    28x
    28x

    28x

    109x

    109x
    1030x

    108x

     const parse = require('./parse');
    const schema = require('./schema');
    const env = require('./env');

    // Accept the user options (first argument) and then a list with all the plugins
    // This will allow us to use the plugin's schemas as well
    module.exports = async (user = {}, plugins = []) => {

      // First and most important is the core and the user-defined options
      const options = await parse(schema, user, env);

      // Then load plugin options namespaced with the name in parallel
      await Promise.all(plugins.map(async ({ name, options: def = {}} = {}) => {
        options[name] = await parse(def, user[name], env, options);
      }));

      return options;
    };