Giter Site home page Giter Site logo

sqs's Introduction

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 }
  • 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, attribute_names = [] } = {})
    • message bodies are parsed via JSON.parse(message)
    • returns { body, message_id, md5_of_body, receipt_handle, attributes }
  • 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

sqs's People

Contributors

artskydj avatar micahswab avatar saibotsivad avatar tehshrike avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.