packages/lambda/src/index.js
function loadLambda(lambdaPath, identifier) {
  return plugin.myrmex.fire('beforeLambdaLoad', lambdaPath, identifier)
  .spread((lambdaPath, identifier) => {
    // Because we use require() to get the config, it could either be a JSON file
    // or the content exported by a node module
    // But because require() caches the content it loads, we clone the result to avoid bugs
    // if the function is called twice.
    const lambdaConfig = _.cloneDeep(require(path.join(lambdaPath, 'config')));

    // If the identifier is not specified, it will be the name of the directory that contains the config
    lambdaConfig.identifier = lambdaConfig.identifier || identifier;

    // Lasy loading because the plugin has to be registered in a Myrmex instance before requiring ./lambda
    const Lambda = require('./lambda');
    const lambda = new Lambda(lambdaConfig, lambdaPath);

    // This event allows to inject code to alter the Lambda configuration
    return plugin.myrmex.fire('afterLambdaLoad', lambda);
  })
  .spread((lambda) => {
    return Promise.resolve(lambda);
  });
}
function loadLambda(lambdaPath, identifier) {
  return plugin.myrmex.fire('beforeLambdaLoad', lambdaPath, identifier)
  .spread((lambdaPath, identifier) => {
    // Because we use require() to get the config, it could either be a JSON file
    // or the content exported by a node module
    // But because require() caches the content it loads, we clone the result to avoid bugs
    // if the function is called twice.
    const lambdaConfig = _.cloneDeep(require(path.join(lambdaPath, 'config')));

    // If the identifier is not specified, it will be the name of the directory that contains the config
    lambdaConfig.identifier = lambdaConfig.identifier || identifier;

    // Lasy loading because the plugin has to be registered in a Myrmex instance before requiring ./lambda
    const Lambda = require('./lambda');
    const lambda = new Lambda(lambdaConfig, lambdaPath);

    // This event allows to inject code to alter the Lambda configuration
    return plugin.myrmex.fire('afterLambdaLoad', lambda);
  })
  .spread((lambda) => {
    return Promise.resolve(lambda);
  });
}
function loadLambda ( lambdaPath , identifier ) { return plugin . myrmex . fire ( 'beforeLambdaLoad' , lambdaPath , identifier ) . spread ( ( lambdaPath , identifier ) => { // Because we use require() to get the config, it could either be a JSON file // or the content exported by a node module // But because require() caches the content it loads, we clone the result to avoid bugs // if the function is called twice. const lambdaConfig = _ . cloneDeep ( require ( path . join ( lambdaPath , 'config' ) ) ) ; // If the identifier is not specified, it will be the name of the directory that contains the config lambdaConfig . identifier = lambdaConfig . identifier || identifier ; // Lasy loading because the plugin has to be registered in a Myrmex instance before requiring ./lambda const Lambda = require ( './lambda' ) ; const lambda = new Lambda ( lambdaConfig , lambdaPath ) ; // This event allows to inject code to alter the Lambda configuration return plugin . myrmex . fire ( 'afterLambdaLoad' , lambda ) ; } ) . spread ( ( lambda ) => { return Promise . resolve ( lambda ) ; } ) ; }
Load a lambda
@param {string} lambdaPath - path to the Lambda module
@param {string} identifier - the lambda identifier
@returns {Promise<Lambda>} - the promise of a lambda
Load a lambda