我在cdk 研讨会上创建了一个小型 lambda 函数。我正在打字稿中编写 lambda 函数,通过管道进行部署,该管道创建包含 lambda 函数的云形成堆栈。
我正在尝试在 lambda 中使用 sdk v3,如此处演示的那样。但后来我在这里看到了相互矛盾的文档。
这些错误是因为我尝试使用 V3 而我不应该使用,还是因为其他原因?处理程序设置正确,函数运行但失败并出现错误:
{
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module '@aws-sdk/client-sns'\nRequire stack:\n- /var/task/ReceiveMessageLoraThing.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
"stack": [
"Runtime.ImportModuleError: Error: Cannot find module '@aws-sdk/client-sns'",
"Require stack:",
"- /var/task/ReceiveMessageLoraThing.js",
"- /var/runtime/UserFunction.js",
"- /var/runtime/index.js",
" at _loadUserApp (/var/runtime/UserFunction.js:100:13)",
" at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
" at Object.<anonymous> (/var/runtime/index.js:43:30)",
" at Module._compile (internal/modules/cjs/loader.js:999:30)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)",
" at Module.load (internal/modules/cjs/loader.js:863:32)",
" at Function.Module._load (internal/modules/cjs/loader.js:708:14)",
" at …Run Code Online (Sandbox Code Playgroud) 我正在测试使用特定对象调用(构造函数)函数,但该对象本身具有 JSON 属性。这是因为我模拟的第三方 API 需要这种类型的对象,所以我无法更改它。
我想通过将它们转换回对象并使用类似的东西来测试这些 JSON 属性expect.objectContaining,因为它比尝试匹配完整对象或更糟糕的是 JSON 字符串更脆弱。
我正在测试 AWS Lambda SNS 发送函数,但我认为这并不完全相关,除了解释我的测试系统的语法之外:
export async function handler(event: any) {
let sns = new SNSClient({ region: REGION });
let myMessage = {}; // create my message
let params = {
Message: JSON.stringify(myMessage),
TopicArn: 'my ARN'
}
const result = await sns.send(new PublishCommand(params));
// some stuff
return true;
}
Run Code Online (Sandbox Code Playgroud)
我的测试:
import { handler } from "./handler";
import { SNSClient, PublishCommand } from "@aws-sdk/client-sns";
const mockSnsSend = jest.fn();
mockSnsSend.mockResolvedValue({ …Run Code Online (Sandbox Code Playgroud) 首先有一些类似的问题,但我已经尝试了我能找到的所有建议,但似乎没有任何效果。如果你能找到我没有提到的,请评论,我会尝试一下。
概要是我正在尝试将 Docker 容器中的 .NET Core 3.1 Web api 连接到主机上的 SQL Server 2019,但失败并显示System.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 0 - Success).
我有:
我努力了:
根据here,人们取得了成功,mcr.microsoft.com/dotnet/core/aspnet:3.1-bionic而不是mcr.microsoft.com/dotnet/core/aspnet:3.1
各种形式docker run,包括-p 1433:1433,,-p 0.0.0.0:1433:1433-p localhost:1433:1433
我的连接字符串当前是
"Server=host.docker.internal;Database=xxx;MultipleActiveResultSets=true;UID=sa;PWD='xxx';Integrated …
我试图在复选框列表中使用去抖动绑定行为,但它似乎没有像我期望的那样工作(我不确定你是否甚至可以去除复选框):
<label repeat.for="v of values">
<input type="checkbox" value.bind="v" checked.bind="checkedVal & debounce:1000"> Checkbox value "${v}"
</label>
Run Code Online (Sandbox Code Playgroud)
点击任何一个复选框会checkedVal立即导致数组更新,而它正如我期望的那样正常输入:
<input type="text" value.bind="textVal & debounce:1000"/>
Run Code Online (Sandbox Code Playgroud)
我可以去掉复选框输入吗?
这是完整的代码,这里有一个GistRun.
app.html:
<template>
<h1>Checkbox bind debounce</h1>
<form>
<label for="text">text input with debounce:1000 </label>
<input type="text" value.bind="textVal & debounce:1000"/>
<div repeat.for="v of values">
<br/>
<label>
<input type="checkbox" value.bind="v" checked.bind="checkedVal & debounce:1000"> Checkbox value "${v}"
</label>
</div>
</form>
<br/>
<p>Text value: ${textVal}</p>
<p>Checked values:</p>
<p repeat.for="v of checkedVal">${v}</p>
</template>
Run Code Online (Sandbox Code Playgroud)
app.js:
export class …Run Code Online (Sandbox Code Playgroud) 我正在编写一个 .NET MAUI 应用程序,我想在我的 ViewModel 中使用Microsoft.Maui.Storage.Preferences,但是不希望将我的 ViewModel 绑定到静态Preferences类,否则将很难测试。所以我注意到有一个IPreferences接口,但我不知道它的目的是什么,因为我无法注入静态实现(并且首选项是静态的)。
在我的启动课程中,我做了通常的builder.Services.AddSingleton()事情.AddTransient():
builder.Services
.AddSingleton<AppShell>()
.AddTransient<MyViewModel>()
...
Run Code Online (Sandbox Code Playgroud)
但我不能用静态类来做到这一点。这是行不通的,因为你不能使用静态类作为类型参数:
.AddSingleton<IPreferences, Preferences>()
Run Code Online (Sandbox Code Playgroud)
这不起作用,因为框架不提供它:
.AddSingleton<IPreferences>()
Run Code Online (Sandbox Code Playgroud)
我试着变得更奇特:
.AddSingleton<IPreferences>(_ => Preferences.Default)
Run Code Online (Sandbox Code Playgroud)
但我在使用它时收到此错误:
_preferences.Get("SomeKey", DateTime.Now); // error here, but _preferences is defined
Run Code Online (Sandbox Code Playgroud)
[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object.
[mono-rt] at Microsoft.Maui.Storage.PreferencesImplementation.Get[DateTime](String key, DateTime defaultValue, String sharedName) in D:\a\_work\1\s\src\Essentials\src\Preferences\Preferences.android.cs:line 141
[mono-rt] at ... my filenames removed ... in ...\Shells\AppShell.xaml.cs:line 51
[mono-rt] …Run Code Online (Sandbox Code Playgroud) .net ×1
.net-core ×1
aurelia ×1
aws-lambda ×1
aws-sdk-js ×1
docker ×1
jestjs ×1
maui ×1
sql-server ×1
typescript ×1