{"id":19274082,"url":"https://github.com/sbstjn/lawos","last_synced_at":"2025-04-21T22:33:32.075Z","repository":{"id":137671208,"uuid":"84007753","full_name":"sbstjn/lawos","owner":"sbstjn","description":"SQS Worker for AWS Lambda.","archived":false,"fork":false,"pushed_at":"2018-02-12T07:00:00.000Z","size":48,"stargazers_count":28,"open_issues_count":5,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-17T04:03:40.567Z","etag":null,"topics":["amazon","aws","lambda","sqs","sqs-poller","sqs-queue","worker"],"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/sbstjn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-05T22:41:54.000Z","updated_at":"2023-09-13T01:47:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"e194fa67-cb95-4870-bceb-83e3c775595e","html_url":"https://github.com/sbstjn/lawos","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbstjn%2Flawos","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbstjn%2Flawos/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbstjn%2Flawos/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbstjn%2Flawos/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sbstjn","download_url":"https://codeload.github.com/sbstjn/lawos/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250145420,"owners_count":21382411,"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":["amazon","aws","lambda","sqs","sqs-poller","sqs-queue","worker"],"created_at":"2024-11-09T20:45:00.924Z","updated_at":"2025-04-21T22:33:31.755Z","avatar_url":"https://github.com/sbstjn.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lawos - Lambda Worker SQS\n\n[![npm](https://img.shields.io/npm/v/lawos.svg)](https://www.npmjs.com/package/lawos)\n[![license](https://img.shields.io/github/license/sbstjn/lawos.svg)](https://github.com/sbstjn/lawos/blob/master/LICENSE.md)\n[![CircleCI](https://img.shields.io/circleci/project/github/sbstjn/lawos/master.svg)](https://circleci.com/gh/sbstjn/lawos)\n[![Coveralls](https://img.shields.io/coveralls/sbstjn/lawos.svg)](https://coveralls.io/github/sbstjn/lawos)\n\nLibrary to process messages from an Amazon SQS queue with an AWS Lambda worker function or your favorite other JavaScript environment. Works fine with [Serverless](https://github.com/sbstjn/lawos-serverless) …\n\n## Examples\n\n- [Serverless Amazon SQS Worker with AWS Lambda](https://sbstjn.com/serverless-sqs-worker-with-aws-lambda.html)\n- [Basic usage with AWS Lambda and Serverless](https://github.com/sbstjn/lawos-serverless)\n\n## Install\n\n```bash\n$ \u003e npm install lawos\n```\n\n## Usage\n\n### Promise for every message\n\n```js\nconst AWS = require('aws-sdk');\nconst SQS = new AWS.SQS({apiVersion: '2012-11-05'});\n\nconst Lawos = require('lawos');\nconst Q = new Lawos('https://sqs.eu-west-1.amazonaws.com …', SQS);\n\nQ.item(\n  item =\u003e new Promise(done =\u003e {\n    done();\n  })\n);\n\nmodule.exports.handler = function(event, context, callback) {\n  Q.work(\n    () =\u003e Promise.resolve(context.getRemainingTimeInMillis() \u003c 500)\n  ).then(\n    data =\u003e {\n      callback(null, data);\n    }\n  );\n};\n```\n\n### Promise for a batch of messages\n\n```js\nconst AWS = require('aws-sdk');\nconst SQS = new AWS.SQS({apiVersion: '2012-11-05'});\n\nconst Lawos = require('lawos');\nconst Q = new Lawos('https://sqs.eu-west-1.amazonaws.com …', SQS);\n\nQ.list(\n  list =\u003e new Promise(done =\u003e {\n    done();\n  })\n);\n\nmodule.exports.handler = function(event, context, callback) {\n  Q.work(\n    () =\u003e Promise.resolve(context.getRemainingTimeInMillis() \u003c 500)\n  ).then(\n    data =\u003e {\n      callback(null, data);\n    }\n  );\n};\n```\n\n### Use AWS Lambda instead of Promise\n\n```js\nconst AWS = require('aws-sdk');\nconst Lawos = require('lawos');\n\nconst Lambda = new AWS.Lambda({apiVersion: '2015-03-31'});\nconst SQS = new AWS.SQS({apiVersion: '2012-11-05'});\n\nconst Q = new Lawos('https://sqs.eu-west-1.amazonaws.com …', SQS, Lambda);\n\nQ.item('fake-function-name');\n// Q.list('fake-function-name');\n\nmodule.exports.handler = function(event, context, callback) {\n  Q.work(\n    () =\u003e Promise.resolve(context.getRemainingTimeInMillis() \u003c 500)\n  ).then(\n    data =\u003e {\n      callback(null, data);\n    }\n  );\n};\n```\n\n## License\n\nFeel free to use the code, it's released using the [MIT license](https://github.com/sbstjn/lawos/blob/master/LICENSE.md).\n\n## Contributors\n\n- [Sebastian Müller](https://sbstjn.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbstjn%2Flawos","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsbstjn%2Flawos","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbstjn%2Flawos/lists"}