@trex-arms/sqs

    1.0.0 • Public • Published

    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)
    • 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 }
    • send_message_batch: (queue_url, messages)
      • returns an array of { message_id, md5_of_body }
    • receive_message: (queue_url, { max_number_of_messages, visibility_timeout, wait_time_seconds } = {})
      • message bodies are parsed via JSON.parse(message)
      • returns { body, message_id, md5_of_body, 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 test.mjs file.

    Then

    npm t

    Install

    npm i @trex-arms/sqs

    DownloadsWeekly Downloads

    805

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    14 kB

    Total Files

    7

    Last publish

    Collaborators

    • njbotkin
    • artskydj
    • tehshrike