小编Sam*_*ick的帖子

Webpack和AWS Lambda问题 - 模块上缺少处理程序

我正在使用ES6,babel和Webpack 2捆绑AWS Lambda.然后我使用AWS SAM本地运行/测试它.当我点击api时出现以下错误 -

Handler 'handler' missing on module 'dist/main'
Run Code Online (Sandbox Code Playgroud)

这是我的webpack.config.js -

const path = require('path');

module.exports = {
  entry: './index.js',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'main.js',
    libraryTarget: 'commonjs'
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'babel-loader',
        options: {
          plugins: [require('babel-plugin-transform-flow-strip-types')],
          presets: [
            [
              'env',
              {
                target: { node: 6.10 }, // Node version on AWS Lambda
                useBuiltIns: false,
                loose: false,
                exclude: [],
                debug: false
              },
            ],
          ],
        },
      }
    ],
  }
};
Run Code Online (Sandbox Code Playgroud)

以下是已编译的main.js的片段 …

javascript lambda amazon-web-services webpack webpack-2

5
推荐指数
2
解决办法
1635
查看次数

处理 AWS RDS 连接池(使用 POSTGRES 13)和节点 Lambda

我们在 AWS 中使用 RDS 实例,它是 POSTGRES 13。我们有基于节点的 Lambda,可以将数据返回并发布到数据库。目前,他们为每个事务打开和关闭单个连接,我们希望通过实现连接池来优化这一点。

有一项专门为处理数据库连接而设计的 AWS 服务,称为 AWS RDS Proxy,但它与 POSTGRES 13 不兼容。我们正在寻找替代方法,并且非常感谢您在这方面的任何见解。

我们正在考虑将数据库连接拉到 Lambda 处理程序之外,以便它保持状态(直到 Lambda 被删除),但这无法关闭其与数据库的连接,而且我们担心填满所有可用连接。情况可能是这样,也可能不是。

非常感谢,

山姆

postgresql amazon-rds node.js aws-lambda amazon-rds-proxy

5
推荐指数
1
解决办法
7256
查看次数

如何正确设置Marionette EventAggregator作为Require.js模块

我正在尝试将vent/EventAggregator设置为单独的Require.js模块.我使用的是Marionette 1.0.2(我认为它与1.0.0之前的旧版本有不同的实现),其中包含wreqr:此代码来自backbone.marionette.js: -

        // Event Aggregator
// ----------------
// A pub-sub object that can be used to decouple various parts
// of an application through event-driven architecture.

Wreqr.EventAggregator = (function(Backbone, _){
  "use strict";
  var EA = function(){};

  // Copy the `extend` function used by Backbone's classes
  EA.extend = Backbone.Model.extend;

  // Copy the basic Backbone.Events on to the event aggregator
  _.extend(EA.prototype, Backbone.Events);

  return EA;
})(Backbone, _);
Run Code Online (Sandbox Code Playgroud)

当我设置我的vent.js模块应该是什么?像这样: -

define(['marionette'],function(Marionette){
    return new Marionette.EventAggregator();
})
Run Code Online (Sandbox Code Playgroud)

在我的require配置中,我应该明确地包括backbone.wreqr.js吗?或者只是木偶文件(参见上面的代码片段)是否足够?

这里的参考是我的app.js: -

require.config({

    paths : {
        backbone …
Run Code Online (Sandbox Code Playgroud)

requirejs backbone.js marionette

4
推荐指数
1
解决办法
3866
查看次数

是什么导致SyntaxError:下划线模板中出现意外的EOF错误?

当使用下划线模板在Backbone应用程序中呈现html时,我得到一个SyntaxError:意外的EOF输出.这是我的模板: -

<script type="text/template" id="shellmenu-template">
  <div>
    <p>menu template html will go here....</p>
    <div class="menuButtonsContainer">
        <% _.each(menu, function(menuItem){ %>
        <button class="menuButton" id="<%= _.escape(menuItem.id)"><%= _.escape(menuItem.title) %></button>
        <% }); %>
    </div>
  </div>
</script>
Run Code Online (Sandbox Code Playgroud)

这部分特别错误: -

id="<%= _.escape(menuItem.id)"
Run Code Online (Sandbox Code Playgroud)

id属性是一个数字,这里是menuItem对象: -

dataPath: ""
helpType: "default"
id: 0
moduleName: "TestModule"
modulePath: "interaction/test/testmodule"
title: "Test Module Interaction"
Run Code Online (Sandbox Code Playgroud)

我已经尝试将id作为字符串或使其成为下划线模板代码中的title属性,只是为了看看我是否可以获得以任何形状或形式工作的测试用例但是到目前为止我很难过.我有一个类似的模板做了几乎没有错误的相同的事情.

我有什么想法引起这种愚蠢的想法吗?:-)

html javascript backbone.js underscore.js

3
推荐指数
1
解决办法
2万
查看次数