问题标签 [claudia.js]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
387 浏览

node.js - issues with Claudia.js text responses and Alexa

I'm working on a Claudia.js bot that can be reached through Slack, FB messenger, and as an Alexa skill. Supposedly in claudia, you can return plain text and the framework will give it back to the "frontend" correctly... What I have currently have here works fine with FB and Slack, but when I access it through the Alexa "Service Simulator" I always get "The response is invalid." Here is the lambda that uses Claudia.js. Basically it gets messages from the client and then shunts them to another Lambda that is the "AI". Alexa seems to be choking on line 67. Ideas?


Update -- even if I hardcode a plain text string response or use Alexa Message Builder I still get "The response is invalid." as the Service Response is coming back "undefined."

Looking at logs, as soon as the response is returned (for parsing by botBuilder and a pass to Alexa) this error occurs [TypeError: Cannot read property 'replace' of undefined]


Another update:

If I replace return payload.utterance with something like

The problem persists.

Here is where the Json Request comes in, no problem:

Here is the response I get back from the other lambda (the payload):

then:

and then the error:

0 投票
2 回答
864 浏览

node.js - Claudia.js NetworkingError 创建 Lambda 函数 - 120000 毫秒后超时

我已经使用 claudia.js claudia-bot-builder 构建了一个机器人,并且在我今天早上尝试推送更新之前一切正常。现在脚本正在超时。

脚本

错误

我尝试了几个不同的区域(ap-southeast-1、us-east-2 等),但它们似乎都抛出了相同的错误。

我认为这是我的代码,但同样的脚本昨天还在工作,所以我不确定为什么今天不行。

有什么想法可以在哪里查看更多信息?

0 投票
1 回答
1275 浏览

node.js - 无法导入模块“索引”:使用 claudia.js 时 aws 云监视日志中的错误

无法导入模块“索引”:aws 云观察日志中的错误。使用 claudia 上传 lambda 可以正常工作,但 api 不起作用,云监视日志显示以下错误:

0 投票
2 回答
1977 浏览

postman - 使用邮递员测试 POST 请求,如何访问请求中的表单数据?

我已经在谷歌上搜索了几个小时,我需要帮助。我不认为我使用了正确的词。无论如何,我正在使用 Claudia.JS 为我的 AWS Lambda 函数设置一个 POST 请求。以下是该功能的基础知识:

当我使用邮递员测试发布请求时,我返回了请求对象。惊人的。然后我尝试通过表单数据。我将键设置为“用户名”,将值设置为“这是用户名”。这就是 request.body 是什么:

以为我可以返回 request.body.username... 来键入用户名的值...但我错过了一些东西。

如何访问请求中的表单数据?

更新:好的。网站正在获取表单数据,发出post请求……这个函数正在接收post请求?仍然-在邮递员中...如果我将自己的JSON放入...为什么我不能像... request.body.username一样访问request.body?

0 投票
1 回答
389 浏览

node.js - Claudia Api Builder 正在创建 lambda 函数,但未添加触发器

我正在使用 Claduiajs 创建 lambda 函数,但我仍在发现它可以做什么和不能做什么,到目前为止,我能够创建一个连接到 AWS DynamoDB 的 lambda 函数,并且一切都按预期工作,但是当我尝试添加按照本教程使用 Claudia API Builder 在 API中,触发器不会添加到 lambda 函数中。

我在设置 npm 并安装依赖项后采取的步骤是:

第 1 步:将这个函数写在main.js

第 2 步:运行此命令以创建函数和 apiclaudia create --name add-command-for-agent --region ap-southeast-2 --api-module main --timeout 10 --policies policies/*.json 一旦我这样做了,我会在终端中得到这个:

当我去那个网址时,我得到{"message":"Missing Authentication Token"}

当我检查claduia.json由 create 命令创建的文件时,我看不到那里的 url,只有 id 和模块。

当我在 AWS 控制台上检查 lambda 函数时,没有附加任何触发器。

我做错了什么还是一个错误?

0 投票
1 回答
438 浏览

express - 具有多路由 ExpressJS 应用程序的 ClaudiaJs 部署到 AWS Lambda 和 AWS API Gateway

我有一个包含多条路线的 ExpressJS 项目

我已经将 ClaudiaJS 部署到 AWS Lambda,并且部署似乎有效。

之后,我将 AWS API Gateway 配置为调用 Lambda 函数中的不同资源路径。我发现它适用于根路径“/”但是当我尝试从 API Gateway 调用不同的资源路径时,我在 API Gateway 中收到此错误:

此外,我在 Lambda 函数中收到此消息:

目前这是否可以使用 ClaudiaJS 甚至 Lambda 函数中支持的配置(多个资源路径)来实现?有什么经验吗?


更新 1:这对 AWS Lambdas 来说似乎是可能的。请参阅此处:是否可以将 API 网关与 AWS lambda 中的节点路由连接起来?不确定 ClaudiaJS 是否可以管理此用例


更新 2:ClaudiaJS 在他们的支持小组https://gitter.im/claudiajs/claudia中确认,他们的产品可以将多路由 ExpressJS 应用程序部署到单个 AWS Lambda,并将我推荐给https://livebook.manning。 com/#!/book/serverless-apps-with-node-and-claudiajs/chapter-13/v-5/167所以我这边看起来有些配置/调用错误


更新 3:成功调用 2 条路线:

获取 {"message": "Internal server error"} 用于访问 EC2 上的 MongoDB 的第三条路由。看起来是权限问题。

0 投票
1 回答
118 浏览

amazon-web-services - Claudia.js 自动生成的 lambda 函数未显示在 AWS 控制台上

因此,我使用 express.js 创建了一个 restAPI 后端,并使用 claudia.js 将我的端点上传到 lambda 函数,一切都很顺利。端点按预期工作并返回正确的信息。我唯一的问题是,当我转到我的 aws 控制台时,我看不到创建的 lambda 函数。我不确定这个端点的托管位置。使用 claudia.js 时是否有其他人遇到过这个问题?

0 投票
1 回答
1203 浏览

amazon-web-services - Claudia.js create 在 typescript 项目中找不到模块 lambda

在搜索了几个小时后,我无法弄清楚如何在我的项目中正确运行claudia create 。

按照这个教程,我在 AWS 控制台中创建了一个组和一个用户,然后我将密钥添加到了我的.aws/credentials文件中。

然后我运行了正确生成 lambda.js 文件的命令:

claudia --source dist generate-serverless-express-proxy --express-module app

我的lambda.js

然后我尝试在 AWS 上部署 lambda 函数:

claudia create --source dist --profile myprofile --handler lambda.handler --deploy-proxy-api --region eu-west-1

但我收到了这个错误:

验证包 TypeError:“listener”参数必须是 _addListener (events.js:239:11) 处的函数,位于新服务器 (_http_server.js:269:10) 处.createServer (http.js:34:10) 在 Object.createServer (/tmp/IiRPif/my-project-1.0.0-1Yh6Wb/package/node_modules/aws-serverless-express/index.js:155:25) 在目的。(/tmp/IiRPif/my-project-1.0.0-1Yh6Wb/package/lambda.js:13:37) 在 Module._compile (module.js:652:30) 在 Object.Module._extensions..js (模块.js:663:10) 在 Module.load (module.js:565:32) 在 tryModuleLoad (module.js:505:12) 在 Function.Module._load (module.js:497:3) 在 Module.require (module.js:596:17) 在需要 (internal/module.js:11: 18) 在 validatePackage (/usr/local/lib/node_modules/claudia/src/tasks/validate-package.js:16:15) 在 initEnvVarsFromOptions.then.then.then.then.then.then.then.dir (/ usr/local/lib/node_modules/claudia/src/commands/create.js:342:10) 在全新安装后不能需要 ./lambda。检查您的依赖项。

我在这里做错了什么?

我的package.json

我的app.ts

0 投票
1 回答
2322 浏览

mysql - 无法使用 Sequelize 将 id 插入属于外键引用表的表中

我正在使用节点 js 构建无服务器应用程序,并使用 claudia-api-builder 作为在 AWS 中启动 API 的框架。

在 app.js 文件中,我将所需的 api 称为

下面是我的代码:

我正在尝试将 EmailRegistration 表的 emailregistrationid 作为外键引用添加到 ContactDetails 表中。我正在使用 mysql、nodejs 的 sequelize 来达到预期的效果。但是,我得到以下错误:

未处理的拒绝 SequelizeForeignKeyConstraintError: Cannot add or update a child row: a foreign key constraint failed ( inmeeydb. ContactDetails, CONSTRAINT ContactDetails_ibfk_1FOREIGN KEY ( EmailRegistrationId) REFERENCES EmailRegistration( id) ON DELETE CASCADE ON UPDATE CASCADE)

下面是我的 EmailRegistration 模型文件:

下面是我的 Contactdetails 模型文件:

我尝试在两个表中参考以下代码来更改代码,但没有任何效果。

无法分析如何克服这个问题。当我将 nodejs 与 expressjs 一起使用并且没有问题时,这工作正常。它无法识别 ContactDetails 表中的 EmailRegistrationId(查询中缺少的),并将输出显示为

0 投票
2 回答
623 浏览

amazon-web-services - 到达 lambda 函数端点时出现 EROFS 错误

我已经使用 claudiajs 将我的 expressjs 代码部署到 lambda。当我点击生成的 API 端点时,每个备用请求都会给我内部服务器错误。我检查了日志并发现了这个

我无法弄清楚可能是什么问题,为什么它只发生在备用请求而不是每个请求上。我该如何继续呢?任何帮助,将不胜感激。