Created
June 5, 2021 01:50
-
-
Save mosufy/fc5b780c95ad9e245941d21a5f8ad16f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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