{"id":20249147,"url":"https://github.com/aneeshd16/node-sqs-stream","last_synced_at":"2026-05-06T04:05:02.691Z","repository":{"id":43958627,"uuid":"240024749","full_name":"aneeshd16/node-sqs-stream","owner":"aneeshd16","description":"Use Readable and Writable streams for AWS SQS","archived":false,"fork":false,"pushed_at":"2023-01-06T03:33:21.000Z","size":832,"stargazers_count":2,"open_issues_count":10,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-14T18:52:02.168Z","etag":null,"topics":["aws","javascript","nodejs","sqs","stream"],"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/aneeshd16.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-12T13:52:29.000Z","updated_at":"2021-08-18T14:03:23.000Z","dependencies_parsed_at":"2023-02-05T05:32:30.441Z","dependency_job_id":null,"html_url":"https://github.com/aneeshd16/node-sqs-stream","commit_stats":{"total_commits":16,"total_committers":3,"mean_commits":5.333333333333333,"dds":0.1875,"last_synced_commit":"f96cea28f28329680aff7621e4b2ed4301674b15"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aneeshd16%2Fnode-sqs-stream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aneeshd16%2Fnode-sqs-stream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aneeshd16%2Fnode-sqs-stream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aneeshd16%2Fnode-sqs-stream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aneeshd16","download_url":"https://codeload.github.com/aneeshd16/node-sqs-stream/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241696181,"owners_count":20004748,"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":["aws","javascript","nodejs","sqs","stream"],"created_at":"2024-11-14T09:52:25.586Z","updated_at":"2026-05-06T04:05:02.659Z","avatar_url":"https://github.com/aneeshd16.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-sqs-stream\nUse Readable and Writable streams for AWS SQS\n\n## installation\n\n```bash\n$ npm install node-sqs-stream --save\n```\nor\n```bash\n$ yarn add node-sqs-stream\n```\n\n## api reference\n\u003ca name=\"SQSWritableStream\"\u003e\u003c/a\u003e\n\n## SQSWritableStream ⇐ \u003ccode\u003eWritable\u003c/code\u003e\n**Kind**: global class  \n**Extends**: \u003ccode\u003eWritable\u003c/code\u003e  \n\n* [SQSWritableStream](#SQSWritableStream) ⇐ \u003ccode\u003eWritable\u003c/code\u003e\n    * [.SQSWritableStream](#SQSWritableStream.SQSWritableStream)\n        * [new SQSWritableStream()](#new_SQSWritableStream.SQSWritableStream_new)\n\n\u003ca name=\"SQSWritableStream.SQSWritableStream\"\u003e\u003c/a\u003e\n\n### SQSWritableStream.SQSWritableStream\n**Kind**: static class of [\u003ccode\u003eSQSWritableStream\u003c/code\u003e](#SQSWritableStream)  \n\u003ca name=\"new_SQSWritableStream.SQSWritableStream_new\"\u003e\u003c/a\u003e\n\n#### new SQSWritableStream()\nCreates an instance of SQSWritableStream.\n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| options.sqsClient | \u003ccode\u003eObject\u003c/code\u003e | instance of AWS.SQS |\n| options.queueUrl | \u003ccode\u003estring\u003c/code\u003e | URL of the SQS queue |\n| options.sqsBatchSize | \u003ccode\u003eNumber\u003c/code\u003e | No of messages to be sent in one batch |\n\n## use\n```js\nconst sqsClient = new AWS.SQS({apiVersion: '2012-11-05'});\nconst sqsStream = new SQSWritableStream({\n    sqsClient: sqsClient,\n    queueUrl: 'http://example-sqs-url',\n});\nsomeStream.pipe(sqsStream);\n```\n\n## examples\n### Strings/Buffers\n```js\n//pipe contents of a file line by line to SQS without blowing up your memory usage\nconst fs = require('fs');\nconst AWS = require('aws-sdk');\nconst { SQSWritableStream } = require('../index');\nconst { Transform } = require('stream');\n\nconst sqsClient = new AWS.SQS({apiVersion: '2012-11-05'});\nconst readStream = fs.createReadStream(__dirname + '/test');\nconst sqsStream = new SQSWritableStream({\n    sqsClient: sqsClient,\n    queueUrl: 'http://example-sqs-url',\n});\nconst splitLines = new Transform({\n    writableObjectMode: true,\n    transform(chunk, encoding, callback) {\n        const lines = chunk.toString().split('\\n');\n        for (let i = 0; i \u003c lines.length; i++) {\n            const line = lines[i];\n            this.push(line);\n        }\n        callback();\n    }\n})\nreadStream.on('end', () =\u003e {\n    console.log('Finished reading');\n});\nsqsStream.on('finish', () =\u003e {\n    console.log('Finished writing');\n})\nreadStream.pipe(splitLines).pipe(sqsStream);\n```\n\n### Full SQS Message\n```js\nconst fs = require(\"fs\");\nconst AWS = require(\"aws-sdk\");\nconst { SQSWritableStream } = require(\"../index\");\nconst { Transform } = require(\"stream\");\nconst uuidv4 = require(\"uuid/v4\");\n\nconst sqsClient = new AWS.SQS({ apiVersion: \"2012-11-05\" });\nconst readStream = fs.createReadStream(__dirname + \"/test\");\nconst sqsStream = new SQSWritableStream({\n\tsqsClient: sqsClient,\n\tqueueUrl: \"https://example-test\"\n});\nconst splitLines = new Transform({\n\tobjectMode: true,\n\ttransform(chunk, encoding, callback) {\n\t\tconst lines = chunk.toString().split(\"\\n\");\n\t\tfor (let i = 0; i \u003c lines.length; i++) {\n\t\t\tconst line = lines[i];\n\t\t\tthis.push({\n\t\t\t\tId: uuidv4(),\n\t\t\t\tMessageBody: line,\n\t\t\t\tDelaySeconds: 10,\n\t\t\t\tMessageAttributes: {\n\t\t\t\t\t\"RequestId\": {\n\t\t\t\t\t\tDataType: \"String\",\n\t\t\t\t\t\tStringValue: \"Some auto generated requestId\"\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tMessageDeduplicationId: uuidv4(),\n\t\t\t\tMessageGroupId: uuidv4(),\n\t\t\t\t// MessageSystemAttributes: {\n\t\t\t\t// \t\"AWSTraceHeader\": {\n\t\t\t\t// \t\tDataType: \"String\",\n\t\t\t\t// \t\tStringValue: \"xyz\"\n\t\t\t\t// \t}\n\t\t\t\t// }\n\t\t\t});\n\t\t}\n\t\tcallback();\n\t}\n});\nreadStream.on(\"end\", () =\u003e {\n\tconsole.log(\"Finished reading\");\n});\nsqsStream.on(\"finish\", () =\u003e {\n\tconsole.log(\"Finished writing\");\n});\nsqsStream.on('error', (error) =\u003e {\n    console.error(error)\n})\nreadStream.pipe(splitLines).pipe(sqsStream);\n\n```\n\nThe stream uses batching to reduce calls to SQS.\n\nThis is especially useful when doing [ETL](http://en.wikipedia.org/wiki/Extract,_transform,_load).\n\n## license\n\nThe MIT License (MIT)\n\nCopyright (c) 2013-2020 Brian M. Carlson\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faneeshd16%2Fnode-sqs-stream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faneeshd16%2Fnode-sqs-stream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faneeshd16%2Fnode-sqs-stream/lists"}