Tag: lambda

节点asynchronous仅在node-lambda内部调用第一个函数

使用像下面的节点asynchronous的香草节点脚本工作得很好: async = require('async'); async.waterfall([ function (c) { console.log(1); c(null); }, function (c) { console.log(2); c(null); } ]); 上面通过node test.js运行时输出: 1 2 ……如预期的那样。 但是,如果我把代码放在node-lambda处理程序中: var async = require('async'); exports.handler = function( event, context ) { console.log( "=================================="); async.waterfall([ function (c) { console.log(1); c(null); }, function (c) { console.log(2); c(null); } ]); console.log( "=================================="); context.done( ); […]

使用webpack在lambda中集成mongoose

我试图设置一个nodejs lambda服务,它使用mongoose连接到一个mongodb。 概要 该webpack调用包含一些警告,没有错误。 lambda服务返回“无法find模块”./node-mongodb-native'。“ 相关链接 尝试在使用Webpack作为模块Bundler的nodejs应用程序中使用mongoose https://github.com/webpack/webpack/issues/1040 https://github.com/Automattic/mongoose/issues/3578 尝试在Webpack上使用带有node-webkit目标的mongoose 细节 webpack调用返回 ./node_modules/.bin/webpack -p –config config/webpack.config.babel.js –display-error-details … WARNING in ./~/mongoose/lib/drivers/index.js Critical dependencies: 8:11-74 the request of a dependency is an expression @ ./~/mongoose/lib/drivers/index.js 8:11-74 WARNING in ./~/mongoose/lib/drivers/SPEC.md Module parse failed: /pathReplacement/node_modules/mongoose/lib/drivers/SPEC.md Unexpected character '#' (2:0) You may need an appropriate loader to handle this […]

Ffmpeg无法访问aws labmda上的文件

我正在使用ffmpeg在AWS Lambda上创buildvideo缩略图。 我在/ tmp目录中下载了这个文件,但是ffmpeg无法访问它并给出错误 [错误:元数据不包含持续时间,中止截图创build] 当我使用ffmpeg检查媒体信息时,它将输出结果 { ffmpegversion: 0, title: '', artist: '', album: '', track: '', date: '', durationraw: '', durationsec: 0, synched: false, major_brand: undefined, video: { container: '', bitrate: 0, codec: '', resolution: { w: 0, h: 0 }, resolutionSquare: { w: 0, h: NaN }, rotate: 0, fps: 0, stream: 0, […]

运行脚本时数据不刷新(NodeJs Lambda Alexa Skill)

我创build了一个运行NodeJs的Lambda项目。 当我运行脚本时,它从我的外部网站(JSON数据)获取值。 如果我更改数据,然后重新运行该脚本,它不会更新值,直到我再次运行该脚本。 所以我必须运行这个脚本两次才能让脚本获得JSON数据。 有谁知道如何解决这个问题,脚本的一部分低于要求从我的服务器获取值的地方: var http = require('http'); http.get('http://1**.24.**.2*5/data.php', function(res){ var body = ''; res.on('data', function(data){ res.body = ""; body += data; }); res.on('end', function(){ boatdata = JSON.parse(body); }); }).on('error', function(e){ console.log('Http Error: ' + e); });

从module.exports对象数组中检索值

我试图从这个module.export数组中检索值,我只是不能。 你可以帮我吗? 这是words.js module.exports = { "word1": 'phrase1', "word2": 'phrase2', "word3": 'phrase3', "word4": 'phrase4', "word5": 'phrase5' }; 而在main.js我打电话 var recipes = require('./words'); 现在,我如何检索在main.js中使用的words.js的值 我的意思是,如果我想得到一个随机数[3],然后显示相应的值[短语4]? 这是我正在尝试做的,但它根本不起作用。 var factIndex = Math.floor(Math.random() * recipes.length); var randomFact = recipes[factIndex]; 请帮忙。 谢谢!

从AWS Lambda修改Google表格

我正在开发一个小项目,我对使用Google云端硬盘感兴趣。 该程序的主要前提是将lambda函数激活时插入一个新的行到谷歌表。 我宁愿为这个项目使用Node.js,但是可以使用Java或Python。 从教程网站很容易看到这一切如何运作。 你提出一个请求,你有OAuth,然后程序按照它的要求去做。 不过,我正在寻找一种方法,让我的AWS lambda函数与我的谷歌驱动器中的文件夹交谈,并随意更新工作表。 本教程中的代码如下所示: var fs = require('fs'); var readline = require('readline'); var google = require('googleapis'); var googleAuth = require('google-auth-library'); // If modifying these scopes, delete your previously saved credentials // at ~/.credentials/drive-nodejs-quickstart.json var SCOPES = ['https://www.googleapis.com/auth/drive.metadata.readonly']; var TOKEN_DIR = (process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE) + '/.credentials/'; var TOKEN_PATH = TOKEN_DIR […]

Alexa podcast技能套件,从远程json加载audio文件

所以,我试图用json来加载这个audio数据: https : //github.com/alexa/skill-sample-nodejs-audio-player/ 使用请求( https://github.com/request/request )来获取json数据就像一个testing,我运行这个代码。 情节被定义为请求之外的数组。 request.get('myjsondatalink.asp', function (error, response, body) { if(error) { episodes[0] = 'soundcloud-url'; console.log(error); } if (!error && response.statusCode == 200) { var podcasts = body; episodes[0] = 'soundcloud-url'; } episodes[0] = 'soundcloud-url'; }); 我知道请求之外的代码工作,因为我已经尝试声明请求之外的情节[0],它播放良好。 控制台不给我任何错误,我已经尝试只是包括在索引中的这个请求的东西,我可以得到它至less略微工作(可以得到它在成功的请求控制台日志的东西)。 任何理由,这将无法正常工作? 最初是3秒钟超时,所以我把它增加到了30,这是我能得到索引中testing请求的唯一方法。 就像一个笔记,我跑了 for(var podcast in podcasts) { console.log(podcast); } 并且它像1439,1440,1441,1442,1443等那样熄灭,而不是string。 也不太确定,但我不熟悉节点,所以我认为这是错的?

AWS Lambda和Dynamo:一个或多个参数值无效

我刚开始使用AWS,我试图通过从DynamoDB发布/获取的API Gateway启动并运行Lambda。 我正在使用dynamodb-doc的内联代码编辑器。 我不断得到错误: One or more parameter values were invalid: Condition parameter type does not match schema type 我不确定这是为什么。 我的表在Dynamo中设置,分区键为BusinessAsset_ID和GSI BusinessAsset_ID-index。 奇怪的是,我的POST实际上工作,并成功地将项目放入Dynamo。 我的代码如下。 提前致谢! 编辑:我正在使用“Lambda函数”集成types和“使用Lambda代理集成”checkbox的API网关GET方法。 我也尝试使用该方法作为具有path覆盖和执行angular色的“AWS服务”。 它导致与上面相同的错误消息相同的502错误的网关错误。 'use strict'; const doc = require('dynamodb-doc'); const dynamo = new doc.DynamoDB(); exports.handler = function(event, context) { switch (event.httpMethod) { case 'GET': var params = { TableName: event.queryStringParameters.TableName, […]

aws api网关,lambda和node express

我正在尝试在lambda和api网关上部署我的快速应用程序。 我使用Claudia.js来完成这个工作来包装我的快速应用程序。 这是我的路线: app.get("/", function(req, res){ res.render("hello.ejs"); }); app.get("/redirect", function(req, res){ res.redirect("/"); }); 在我的hello.ejs中,它包含: <a href="/redirect"> redirect </a> 然后我用lambda创build了根API“/”,hello.ejs通过api成功呈现。 但是,当我点击redirect链接时,显示{“message”:“Forbidden”}。 api的url也会被aws,xxxx.com/"deploy stage“修改”/这个成为根路由,当我点击“redirect”链接时,url变成了xxxx.com/redirect,合理。 我修改了url为xxxx.com/"deploy stage“/ redirect,并且{”message“:”Missing Authentication Token“}出现了。 请帮忙!

如何与亚马逊的物联网可编程button的LED灯交互

我正在使用node.js在Amazon Web Services中创buildIoTbutton在按下时调用的Lambda函数。 IoTbutton带有一个小的LED,如果该function成功执行,该LED将点亮为绿色,如果出现错误则为红色。 我想知道是否有任何方法来控制LED比这更多? 我知道它在configuration过程中闪烁白色。 我已经阅读了相当多的文档,找不到控制LED的任何内容。 有没有人在这里知道很多关于如何告诉button来改变LED的颜色,亮度或持续时间的build议? 我认为这是通过Lambdacallback函数发送的对象完成的,但是我不知道该对象需要使用哪种格式才能使IoTbutton变得有意义。 callback(Error error, Object success) 我可能会补充说,我已经把所有的东西都做好了,而且我也不需要帮忙设置我的button。 我也知道button发送Lambda时按下的是什么: { "serialNumber": "0000000000000000", "batteryVoltage": "xxmV", "clickType": "SINGLE" | "DOUBLE" | "LONG" } 编辑: 所以我发现有人把固件的某个不可编程的仪表板button丢了 ,我发现这个: Usage: led <r> <g> <b> Usage: led <mode> <r> <g> <b> Modes: 'b'==blink; 'f'==fade Illuminating LED with RGB(%x,%x,%x) color=%8x 虽然我不知道该怎么办