lib/tck/lambdas/chistacojs/source/chistescortos.js in tck-lambdas-0.3.0 vs lib/tck/lambdas/chistacojs/source/chistescortos.js in tck-lambdas-0.3.1
- old
+ new
@@ -1,17 +1,21 @@
/* Copyright 2016 The Cocktail Experience, S.L. */
-
-module.exports = {
- call: function(request, conf, callback) {
- var url = conf.chistescortos.url;
- request(url, function (error, response, body) {
- if (!error && response.statusCode == 200) {
- var cheerio = require('cheerio'),
- body = cheerio('body', body);
- callback(null, body('.post .oldlink').text());
- }
- else {
- callback(error, response.statusCode);
- }
- })
- }
+module.exports = function(tck_lambdas_conf) {
+ var conf = tck_lambdas_conf.modules[1], // "chistescortos"
+ module = {
+ name: conf.name,
+ conf: conf,
+ call: function(request, callback) {
+ request(conf.url, function (error, response, body) {
+ if (!error && response.statusCode == 200) {
+ var cheerio = require('cheerio'),
+ dom = cheerio.load(body);
+ callback(null, dom('.post .oldlink').html());
+ }
+ else {
+ callback(error, response.statusCode);
+ }
+ })
+ }
+ };
+ return(module);
}