@remit/smtp-worker 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/smtp-worker",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "exports": {
@@ -2,11 +2,9 @@
2
2
  import {
3
3
  DeleteMessageCommand,
4
4
  ReceiveMessageCommand,
5
- SQSClient,
6
5
  } from "@aws-sdk/client-sqs";
7
- import { AwsQueryProtocol } from "@aws-sdk/core/protocols";
8
6
  import { createLogger } from "@remit/logger-lambda";
9
- import { resolveSqsCredentials } from "@remit/sqs-client";
7
+ import { createQueueProducer } from "@remit/sqs-client/producer";
10
8
  import type { Context, SQSBatchResponse, SQSEvent } from "aws-lambda";
11
9
  import { env } from "expect-env";
12
10
  import { handler } from "./index.js";
@@ -32,12 +30,7 @@ const queueUrl = env.SQS_QUEUE_URL_SMTP;
32
30
  const queueName = new URL(queueUrl).pathname.split("/").pop();
33
31
  const log = createLogger().child({ queue: queueName });
34
32
 
35
- const isLocal = queueUrl.startsWith("http://localhost");
36
- const sqs = new SQSClient({
37
- endpoint: isLocal ? new URL(queueUrl).origin : undefined,
38
- ...(isLocal && { protocol: AwsQueryProtocol }),
39
- credentials: resolveSqsCredentials(),
40
- });
33
+ const sqs = createQueueProducer({ queueUrl });
41
34
 
42
35
  const maxMessages = 10;
43
36
 
@@ -1,6 +1,5 @@
1
1
  import { randomUUID } from "node:crypto";
2
- import { SendMessageCommand, SQSClient } from "@aws-sdk/client-sqs";
3
- import { AwsQueryProtocol } from "@aws-sdk/core/protocols";
2
+ import { SendMessageCommand } from "@aws-sdk/client-sqs";
4
3
  import { deriveAddressId, deriveMessageId } from "@remit/data-ports/id";
5
4
  import type { ConnectionState } from "@remit/domain-enums";
6
5
  import type { Logger } from "@remit/logger-lambda";
@@ -21,7 +20,7 @@ import {
21
20
  createSecretsService,
22
21
  } from "@remit/secrets-service";
23
22
  import { sendMail } from "@remit/smtp-service";
24
- import { resolveSqsCredentials } from "@remit/sqs-client";
23
+ import { createQueueProducer } from "@remit/sqs-client/producer";
25
24
  import { env } from "expect-env";
26
25
  import { buildDataPortsFromEnv, type SmtpDataPorts } from "../data-ports.js";
27
26
  import type { SendMessageEvent } from "../events.js";
@@ -59,12 +58,8 @@ const getTokenService = () => {
59
58
  // APPEND_SENT_MESSAGE is processed by the IMAP worker via the
60
59
  // message-management queue (see remit-imap-worker/src/emit.ts).
61
60
  const messageMgmtQueueUrl = env.SQS_QUEUE_URL_MESSAGE_MGMT;
62
- const isLocalQueue = messageMgmtQueueUrl.startsWith("http://localhost");
63
-
64
- const messageMgmtSqs = new SQSClient({
65
- endpoint: isLocalQueue ? new URL(messageMgmtQueueUrl).origin : undefined,
66
- ...(isLocalQueue && { protocol: AwsQueryProtocol }),
67
- credentials: resolveSqsCredentials(),
61
+ const messageMgmtSqs = createQueueProducer({
62
+ queueUrl: messageMgmtQueueUrl,
68
63
  });
69
64
 
70
65
  const emitAppendSentMessage = async (