{"id":13755181,"url":"https://github.com/onebeyond/systemic-aws-sqs","last_synced_at":"2025-05-10T00:31:39.639Z","repository":{"id":44998687,"uuid":"347121788","full_name":"onebeyond/systemic-aws-sqs","owner":"onebeyond","description":"systemic-aws-sqs","archived":true,"fork":false,"pushed_at":"2023-07-04T13:49:39.000Z","size":598,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-05-07T11:56:18.518Z","etag":null,"topics":["hacktoberfest"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/onebeyond.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-12T16:03:00.000Z","updated_at":"2023-07-04T14:06:39.000Z","dependencies_parsed_at":"2024-08-03T10:02:11.669Z","dependency_job_id":"7bcf5ee3-e197-4e14-ac7a-fa68c0d0cb8f","html_url":"https://github.com/onebeyond/systemic-aws-sqs","commit_stats":null,"previous_names":["guidesmiths/systemic-aws-sqs"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onebeyond%2Fsystemic-aws-sqs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onebeyond%2Fsystemic-aws-sqs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onebeyond%2Fsystemic-aws-sqs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onebeyond%2Fsystemic-aws-sqs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/onebeyond","download_url":"https://codeload.github.com/onebeyond/systemic-aws-sqs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253346490,"owners_count":21894264,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest"],"created_at":"2024-08-03T10:00:48.256Z","updated_at":"2025-05-10T00:31:39.097Z","avatar_url":"https://github.com/onebeyond.png","language":"JavaScript","funding_links":[],"categories":["Modules"],"sub_categories":[],"readme":"# ⚠️ This repository is not longer maintained ⚠️\n\nThis project is not longer maintained and has been archived. More details in [One Beyond Governance Tiers](https://onebeyond-maintainers.netlify.app/governance/tiers)\n\n# Systemic AWS SQS\n\nA [Systemic](https://guidesmiths.github.io/systemic/#/) component for the [AWS SQS SDK v3](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/index.html).\n\n## How to use it\n\n### Configuration\n\nA typical, simple configuration looks like this:\n\n```json\n{\n  \"region\": \"us-east-1\",\n  \"credentials\": {\n    \"secretAccessKey\": \"test\",\n    \"accessKeyId\": \"test\"\n  }\n}\n```\n\n[Here](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-sqs/interfaces/sqsclientconfig.html) you can find the complete configuration interface of SQSClient class constructor that set the region, credentials and other options.\n\n### Initialize the component\n\nAs with any other [Systemic component](https://guidesmiths.github.io/systemic/#/?id=components), you can run it with the `start` method:\n\n```js\nconst initAWSSQS = require('systemic-aws-sqs');\nconst { start } = initAWSSQS();\n\nconst api = await start({ config }); // configuration similar to the one above\n```\n\n### Call the API commands\n\nAs the AWS API has dozens of commands, intead of having one wrapper for each of them, the component exposes one single command `commandExecutor` that can be used to call any of the commands exposed by the api:\n\n```js\nconst res = await api.commandExecutor({\n  commandParams: { \u003cparams of the method\u003e },\n  commandName: \u003cname of the method\u003e\n});\n```\n\nFor example, to create a sqs queue:\n\n```js\nconst createSQSQueue = {\n  commandParams: { QueueName: queueName },\n  commandName: 'createQueue'\n}\nconst res = await api.commandExecutor(createSQSQueue);\n```\n\nYou can check all the available commands [here](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-sqs/classes/sqs.html).\n\n## Custom commands\n\nHere is the current list of the custom commands that extends the SQS sdk functionality\n\n### ListenQueue\n\nThis command will execute a repeated polling of messages in the queue. This iterative polling process will last until it is explicitly stopped.\n\nThis command requires the following parameters: \n\n| Name | Type | Required | Default Value | Description |\n|:----:|:----:|:--------:|:-------------:|:-----------:|\n|awsAccountId  |  string | Yes | - | Id of the AWS account who owns the SQS queue |\n|queueName  |  string | Yes | - | Name of the queue to listen to |\n|processMessage  | async function | yes | - | Function to execute when a message is received from the queue. This function will receive the message as input  |\n|queueName  |  string | Yes | - | Name of the queue to listen to |\n|pollingPeriod  | number | No | 1000 | Milliseconds between each polling process |\n\n#### Returned Object\n\nThe `listenQueue` command will return an object with the following fields: \n- `start(): Promise\u003cnull\u003e` once it is called, the listener will start polling messages from the queue.\n- `stop(): Promise\u003cnull\u003e` it will stop from polling messages from the queue. In case a polling is currently in process, it will wait until it finishes\n- `events` an `EventEmitter` object that will emit the following events:\n    - `messageProcessed` when a message is processed.\n    - `pollingFinished` when a polling processed has been completed, even if a message was received or not.\n    \n`events` field is very useful for testing purposes and for some custom actions.\n\n#### Code example\n\n```js\nconst awsAccountId = '000000000000'\nconst queueName = 'test-service_v1_test-event'\nconst processMessage = (message) =\u003e console.log(message)\nconst pollingPeriod = 1000\n\nconst listener = await sqs.commandExecutor({\n  commandParams: {\n    queueName,\n    awsAccountId,\n    processMessage,\n    pollingPeriod\n  },\n  commandName: 'listenQueue'\n})\n\nawait listener.start()  // starting listening to the queue\n\n// Printing all messages in the queue in console\n\nawait listener.stop()  // stop listening to the queue\n\n// No more messages printed\n```\n\n## Guide for developers\n\n### How to test it\n\nYou can test the whole test suite running one of these commands:\n\nOnce resources are up you can test the component running one of this commands:\n\n```bash\n# all tests will be executed once\nnpm run test\n\n# tests will be executed every time code changes (useful when coding)\nnpm run test:watch\n```\nIn case that you want to just execute a certain test case, you can also use these scripts to up / tear down the infra.\n\n```bash\nnpm run infra:up\nnpm run infra:down\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonebeyond%2Fsystemic-aws-sqs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fonebeyond%2Fsystemic-aws-sqs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonebeyond%2Fsystemic-aws-sqs/lists"}