Skip to content

Instantly share code, notes, and snippets.

@mosufy
Created June 5, 2021 01:50
Show Gist options
  • Save mosufy/fc5b780c95ad9e245941d21a5f8ad16f to your computer and use it in GitHub Desktop.
Save mosufy/fc5b780c95ad9e245941d21a5f8ad16f to your computer and use it in GitHub Desktop.
import { SQS } from 'aws-sdk';
import db from './utils/db';
export const sendQueue = async (payload, options) => {
const sqs = new SQS(options);
let queued;
try {
queued = await sqs.sendMessage(payload).promise();
console.log('Message sent', queued);
} catch (error) {
console.log('Error sending message to queue', error);
throw new Error(error.message);
}
try {
await db.insertLogRecord(queued);
} catch (error) {
console.log('Failed inserting log record', error);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment