@1auth/notify-sqs

AWS SQS notification implementation for asynchronous message delivery.

Install

npm i @1auth/notify-sqs

Peer dependencies

npm i @aws-sdk/client-sqs

Usage

import * as notify from '@1auth/notify-sqs'

notify.default({
  queueName: process.env.QUEUE_NAME ?? 'notify-queue'
})

Configuration options

OptionTypeDefaultDescription
clientSQSClientCustom SQS client instance
queueNamestringSQS queue name
queueUrlstringFull SQS queue URL (alternative to queueName)
logfunctionLogging function

API

trigger(id, sub, data, notifyOptions)

Send a notification to the configured SQS queue.

The message body is a JSON-stringified object containing:

{
  "id": "template-id",
  "sub": "user-subject",
  "data": { "token": "123456" },
  "options": { "messengers": [{ "type": "email" }] }
}

IAM permissions

The Lambda execution role needs the following SQS permissions:

{
  "Effect": "Allow",
  "Action": ["sqs:SendMessage"],
  "Resource": "arn:aws:sqs:*:*:notify-queue"
}