{"id":18924648,"url":"https://github.com/dash-os/aws-lambda-runner","last_synced_at":"2026-02-03T18:34:27.904Z","repository":{"id":71821417,"uuid":"90850178","full_name":"Dash-OS/aws-lambda-runner","owner":"Dash-OS","description":"Better handling of AWS Lambda Functions","archived":false,"fork":false,"pushed_at":"2019-05-03T23:29:17.000Z","size":393,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-30T11:11:36.238Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/Dash-OS.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-10T10:07:07.000Z","updated_at":"2021-09-17T04:40:17.000Z","dependencies_parsed_at":"2023-06-28T21:31:50.437Z","dependency_job_id":null,"html_url":"https://github.com/Dash-OS/aws-lambda-runner","commit_stats":{"total_commits":36,"total_committers":1,"mean_commits":36.0,"dds":0.0,"last_synced_commit":"754a6cfa4c9d1e1c4741897ed11d8c2de1f87090"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Dash-OS/aws-lambda-runner","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dash-OS%2Faws-lambda-runner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dash-OS%2Faws-lambda-runner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dash-OS%2Faws-lambda-runner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dash-OS%2Faws-lambda-runner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dash-OS","download_url":"https://codeload.github.com/Dash-OS/aws-lambda-runner/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dash-OS%2Faws-lambda-runner/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263697590,"owners_count":23497813,"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":[],"created_at":"2024-11-08T11:07:39.625Z","updated_at":"2026-02-03T18:34:27.853Z","avatar_url":"https://github.com/Dash-OS.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AWS Lambda Runner\n\nA tiny (2KB Compressed \u0026 Minified) wrapper utility to make running your\naws lambda functions cleaner.  Inspired heavily/completely by the [node-apex](https://github.com/apex/node-apex)\nlibrary.  \n\n### Features\n\n - Pairs perfectly with the [apex](https://github.com/apex/apex) serverless solution.\n - Supports [Lambda Proxy Integrations](http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-create-api-as-simple-proxy-for-lambda.html) w/ [API Gateway Proxy](http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-set-up-simple-proxy.html#api-gateway-simple-proxy-for-lambda-input-format).\n - Provide custom headers \u0026 status codes to include with the response.\n - Enable cors for the requests.\n - One function can handle methods and paths.\n\n### Installation\n\n```\nyarn add aws-lambda-runner\n```\n\n***OR***\n\n```\nnpm install --save aws-lambda-runner\n```\n\n### Example\n\n#### Without Default Configuration\n\n```js\nimport run from 'aws-lambda-runner'\n\nexport default run(\n  (body, config) =\u003e ({\n    hello: 'world'\n  })\n)\n```\n\n#### With Default Configuration\n\n```js\nimport run from 'aws-lambda-runner'\n\nexport default run({\n  // Do we want the runner to log to cloudwatch (via console)\n  log: true,\n  // default status code to return to the caller when using proxy integration.\n  statusCode: 200,\n  // do we want to add the 'Access-Control-Allow-Origin' header to our response?\n  cors: true,\n  // do we want to add any headers to the response?  We can add new headers by\n  // mutating the received config object\n  headers: null,\n  // do we want to allow the lambda process to flush the event loop before it freezes\n  // this process? If false, all processing will be frozen immediately upon resolution\n  // of the runner Promise (which calls our function below). (defaults: true)\n  awaitEventLoop: false\n}, async (body, config, ctx, cb) =\u003e {\n  /*\n    Handle our function, the resolution of the promise will be used to\n    populate the body.  This does not need to be an async function, we\n    can return a standard object or promise to be resolved.  \n\n    Errors during execution are caught and passed to the caller.\n  */\n  return {\n    hello: 'world'\n  }\n})\n```\n\n### Plugins\n\nLambda-Runner supports a simple plugin system which allows you to handle various\nhooks during the lifecycle of your Lambda's execution.\n\nPlugins are classes which will be instatiated for each request.  One may optionally\npass settings to the plugin.\n\nPlugins can mutate the various objects.  This allows them to add functionality to\nyour requests such as adding response headers, formatting responses, or anything\nthey might want to accomplish.\n\nIf a plugin returns a `Promise`, the promise will be resolved before continuing.\n\n#### Plugin Hooks\n\n - onBuild\n - onComplete\n\n\u003e At some point we plan to add a few extra hooks such as \"onError\" and \"onSuccess\"\n\n#### Plugin Example\n\nHere is a very simple example of a plugin which attempts to capture the\nauthorizer claims and/or API Key that was used for the request and moves\nthe data into `config.auth`.\n\n\n\n##### Function\n\n```js\nexport default run({\n  log: 'debug',\n  cors: true,\n  headers: null,\n  awaitEventLoop: false,\n  plugins: [\n    [ AuthorizerPlugin, {\n      removeAuthorizer: false\n    } ],\n    PromiseMapPlugin\n  ]\n}, async (body, config, ctx) =\u003e {\n  /* Your Function */\n}\n```\n\n### Configuration Object\n\n#### Dynamic Configuration Values\n\nBy mutating the `config` object (or setting the values in the runner configuration),\nyou can change how the request will be handled.  This allows you to set the response\ncode, add cors headers, add errors, and control the function.\n\n - log (default: false) \u003c_Boolean_|_Array_\u003e - what level of runner logging should be performed?\n   - \"errors\", \"exceptions\", \"debug\"\n - headers (default: null) \u003c_null_|_Object Literal_\u003e - headers to include with the response.\n - cors | (default: false) \u003c_Boolean_\u003e - should the \"Access-Control-Allow-Origin\" header be added to the response?\n - statusCode (default: 200) \u003c_Number_\u003e - the default status code to respond with if the request is successful.\n - errorCode (default: 400) \u003c_Number_\u003e - the default status code to respond with if errors are encountered.\n - errors (default: []) \u003c_Array_\u003e - an array of errors that should be provided.  If any errors are pushed into this array, an error will be assumed.\n - plugins (default: []) \u003c_Array_\u003e - provided in the initial runner configuration, plugins allow extending the capabilities of the runner through hooks.\n - onError (default: null) \u003c_null_|_Function_\u003e - a function to allow extra handling of encountered errors.\n - [awaitEventLoop](http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-context.html) (default: true) \u003c_Boolean_\u003e - see the provided link, this controls context.callbackWaitsForEmptyEventLoop.\n - methods (default: null) \u003c_null_|_Array_\u003e - an array of methods that should be accepted for this request.  If not defined, all will be accepted.\n\n#### Static Configuration Values\n\nThese values are set internally on the config object.  Mutating these values will generally not affect the normal\noperation of the runner (although it shouldn't be done as plugins may expect these values to be intact).\n\n - isProxy\n - resource\n - path\n - method\n - request\n - client\n - queries (url queries)\n - params (pathParameters)\n - stage (stageVariables)\n\n\u003e More Information will come about these values, here is a stringified example of the `config` object.\n\n```json\n{\n  \"isProxy\": true,\n  \"resource\": \"/web/session\",\n  \"path\": \"/v2/web/session\",\n  \"method\": \"POST\",\n  \"log\": \"debug\",\n  \"statusCode\": 200,\n  \"cors\": true,\n  \"headers\": null,\n  \"errorCode\": 400,\n  \"awaitEventLoop\": false,\n  \"client\": {\n    \"agent\": \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36\",\n    \"forwardedFor\": [\n      \"\u003cmasked-ip\u003e\",\n      \"\u003cmasked-ip\u003e\"\n    ],\n    \"forwardedPort\": 443,\n    \"country\": \"US\",\n    \"sourceIP\": \"\u003cmasked-ip\u003e\"\n  },\n  \"queries\": {\n    \"version\": \"2.0\",\n  },\n  \"params\": {\n    \"user\": \"example_user\",\n  },\n  \"stage\": null,\n  \"errors\": [],\n  \"request\": {\n    \"headers\": {\n      \"Accept\": \"application/json, text/plain, */*\",\n      \"Accept-Encoding\": \"gzip, deflate, br\",\n      \"Accept-Language\": \"en-US,en;q=0.8\",\n      \"Authorization\": \"\u003cmasked-authorization-header\u003e\",\n      \"CloudFront-Forwarded-Proto\": \"https\",\n      \"CloudFront-Is-Desktop-Viewer\": \"true\",\n      \"CloudFront-Is-Mobile-Viewer\": \"false\",\n      \"CloudFront-Is-SmartTV-Viewer\": \"false\",\n      \"CloudFront-Is-Tablet-Viewer\": \"false\",\n      \"CloudFront-Viewer-Country\": \"US\",\n      \"Content-Type\": \"application/json charset=UTF-8\",\n      \"Host\": \"\u003cmasked-host\u003e\",\n      \"Origin\": \"\u003cmasked-origin\u003e\",\n      \"Referer\": \"\u003cmasked-referer\u003e\",\n      \"User-Agent\": \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36\",\n      \"Via\": \"\u003cmasked\u003e\",\n      \"X-Amz-Cf-Id\": \"\u003cmasked\u003e\",\n      \"X-Amzn-Trace-Id\": \"\u003cmasked\u003e\",\n      \"x-api-key\": \"\u003cmasked-api-key\u003e\",\n      \"X-Forwarded-For\": \"\u003cmasked\u003e, \u003cmasked\u003e\",\n      \"X-Forwarded-Port\": \"443\",\n      \"X-Forwarded-Proto\": \"https\"\n    },\n    \"requestContext\": {\n      \"path\": \"/v2/web/session\",\n      \"accountId\": \"\u003cmasked-account-id\u003e\",\n      \"resourceId\": \"\u003cmasked-resource-id\u003e\",\n      \"stage\": \"production\",\n      \"requestId\": \"63851d0d-40d1-11e7-9be4-d54b94333e61\",\n      \"identity\": {\n        \"cognitoIdentityPoolId\": null,\n        \"accountId\": null,\n        \"cognitoIdentityId\": null,\n        \"caller\": null,\n        \"apiKey\": \"\u003cmasked-api-key\u003e\",\n        \"sourceIp\": \"\u003cmasked-ip\u003e\",\n        \"accessKey\": null,\n        \"cognitoAuthenticationType\": null,\n        \"cognitoAuthenticationProvider\": null,\n        \"userArn\": null,\n        \"userAgent\": \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36\",\n        \"user\": null\n      },\n      \"resourcePath\": \"/web/session\",\n      \"httpMethod\": \"POST\",\n      \"apiId\": \"95r35czxwj\"\n    },\n    \"isBase64Encoded\": false\n  }\n}\n```\n\n### Useful Links \u0026 Resources\n\n - [Webpack 2 / Apex / AWS Lambda Runner Example Project](https://github.com/Dash-OS/aws-lambda-runner-example)\n - [apex.run (docs)](http://apex.run/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdash-os%2Faws-lambda-runner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdash-os%2Faws-lambda-runner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdash-os%2Faws-lambda-runner/lists"}