Package Exports
- @trex-arms/sqs
- @trex-arms/sqs/index.mjs
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@trex-arms/sqs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Talk to the SQS API from node or browsers/Cloudflare Workers.
API
All the code is .mjs, so you'll probably need node 14+.
A single function is exported. Pass in your credentials, get back an object with a bunch of functions.
import make_sqs from '@trex-arms/sqs'
const sqs = make_sqs({
access_key_id: process.env.AWS_ACCESS_KEY_ID,
secret_access_key: process.env.AWS_SECRET_ACCESS_KEY,
region: 'us-west-1',
})
sqs.create_queue('roflcopter', {
message_retention_period: 1209600,
}).then(queue_url => {
console.log('the queue url is', queue_url)
})All API functions return a promise.
Functions on the sqs object:
create_queue(name, attributes = {})- returns queue url (string)
get_queue_url(queue_name)- returns queue url (string)
get_queue_attributes(queue_url, attribute_names = [])- returns attributes (object)
delete_queue(queue_url)send_message(queue_url, message, { delay_seconds, message_attribute = {} } = {})- message is converted to JSON via
JSON.stringify(message) - returns
{ message_id, md5_of_body }
- message is converted to JSON via
send_message_batch(queue_url, messages)- returns an array of
{ message_id, md5_of_body }
- returns an array of
receive_message(queue_url, { max_number_of_messages, visibility_timeout, wait_time_seconds, attribute_names = [] } = {})- message bodies are parsed via
JSON.parse(message) - returns
{ body, message_id, md5_of_body, receipt_handle, attributes }
- message bodies are parsed via
delete_message(queue_url, receipt_handle)
Attribute objects are expected to have snake_case properties.
To run the tests
Paste your credentials into the strings at the top of the index.test.mjs file.
Then
npm t