在Node.JS中使用AWS API网关SDK会导致问题
因此,我尝试按照AWS API网关SDK教程在NodeJS应用程序和API网关之间建立安全连接 我的测试函数如下所示:在Node.JS中使用AWS API网关SDK会导致问题,node.js,amazon-web-services,aws-sdk,aws-api-gateway,Node.js,Amazon Web Services,Aws Sdk,Aws Api Gateway,因此,我尝试按照AWS API网关SDK教程在NodeJS应用程序和API网关之间建立安全连接 我的测试函数如下所示: require('./lib/apigClient'); require('./lib/axios/dist/axios.standalone'); require('./lib/CryptoJS/rollups/hmac-sha256'); require('./lib/CryptoJS/rollups/sha256'); require('./lib/C
require('./lib/apigClient');
require('./lib/axios/dist/axios.standalone');
require('./lib/CryptoJS/rollups/hmac-sha256');
require('./lib/CryptoJS/rollups/sha256');
require('./lib/CryptoJS/components/hmac');
require('./lib/CryptoJS/components/enc-base64');
require('./lib/url-template/url-template');
require('./lib/apiGatewayCore/sigV4Client');
require('./lib/apiGatewayCore/apiGatewayClient');
require('./lib/apiGatewayCore/simpleHttpClient');
require('./lib/apiGatewayCore/utils');
var body = {
"type": "the_best_kind",
"status": "processed",
"name": "test123"
};
export function getRatingsTest(req, res) {
var apigClient = apigClientFactory.newClient({
accessKey: 'ACCESS_KEY',
secretKey: 'SECRET_KEY',
sessionToken:'SESSION_TOKEn', //OPTIONAL: If you are using temporary credentials you must include the session token
region: 'eu-west-1' // OPTIONAL: The region where the API is deployed, by default this parameter is set to us-east-1
});
console.log('NEW CLIENT =====', apigClient)
apigClient.calcRatingPost(null, body, null)
.then(function(result){
//This is where you would put a success callback
}).catch( function(result){
//This is where you would put an error callback
});
return res.json({test: 123})
}
我不断收到这样的错误:没有定义apiGateway,没有定义CryptoJs等等。不幸的是,所有11个javascript文件都不是模块化的
在NodeJS中实现此功能的最佳方法是什么?
我还尝试了aws api网关客户端,但还没有成功。我实际上也在寻找解决方案。在我的例子中,我是从AWS APIGateway阶段导出SDK的,希望我可以在几个项目中简单地共享它。SDK的预期用途似乎只是将其加载到web浏览器中。在node.js中完成这项工作似乎还需要大量重写。在我的例子中,我最好编写自己的JS库来与我的API通信。实际上我也在寻找解决方案。在我的例子中,我是从AWS APIGateway阶段导出SDK的,希望我可以在几个项目中简单地共享它。SDK的预期用途似乎只是将其加载到web浏览器中。在node.js中完成这项工作似乎还需要大量重写。在我的例子中,我最好编写自己的JS库来与API通信。