Sha256: 382cba2fc803abcf57040fab000472697d88db0d5577079200f222b5d0caf15c

Contents?: true

Size: 1.55 KB

Versions: 4

Compression:

Stored size: 1.55 KB

Contents

/* Copyright 2016 The Cocktail Experience, S.L. */
var conf = require('./conf'),
    http = require('request'),
    post = require('post_chistaco'),
    // Chistacojs modules
    refreshing_matter = require('./refreshing_matter'),
    chistescortos = require('./chistescortos');

exports.handler = function(event, context) {
  console.log('Received event:', JSON.stringify(event, null, 2));
  console.log('chistacojs lambda version', conf.lambda_version);
  var chistacojs_param, chistacojs_module;
  if (event.module === undefined) {
    console.log('Unspecified "module", choosing a random one...');
    var idx = Math.floor(Math.random() * conf.modules.length);
    chistacojs_param = conf.modules[idx].param;
  } else {
    chistacojs_param = event.module;
  };

  switch(chistacojs_param) {
    case 'chistescortos':
      chistacojs_module = chistescortos(conf);
      break;
    case 'refreshing':
      chistacojs_module = refreshing_matter(conf);
      break;
    default:
      context.fail('module: not found');
      return;
  }

  console.log('Extracting chistaco from "' + chistacojs_module.name + '" module...');
  chistacojs_module.call(http, function(err, chistaco) {
    if (err) {
      console.log(err, err.stack);
      context.fail(err);
    } else {
      console.log("Received: " + chistaco);
      post.call(http, conf, chistaco, function(err, data) {
        if (err) {
          console.log(err, err.stack);
          context.fail(err);
        } else {
          console.log("Response: " + data);
          context.succeed(0);
        }
      });
    }
  });
};

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tck-lambdas-0.3.4 lib/tck/lambdas/chistacojs/source/chistacojs.js
tck-lambdas-0.3.3 lib/tck/lambdas/chistacojs/source/chistacojs.js
tck-lambdas-0.3.2 lib/tck/lambdas/chistacojs/source/chistacojs.js
tck-lambdas-0.3.1 lib/tck/lambdas/chistacojs/source/chistacojs.js