{"id":20000101,"url":"https://github.com/skippyza/lambda-lib","last_synced_at":"2025-07-17T01:33:55.806Z","repository":{"id":80304188,"uuid":"91059558","full_name":"SkippyZA/lambda-lib","owner":"SkippyZA","description":"Collection of decorators to simplify boilerplate for NodeJS lambdas on AWS","archived":false,"fork":false,"pushed_at":"2020-05-27T23:45:40.000Z","size":336,"stargazers_count":1,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-07T15:46:56.251Z","etag":null,"topics":["decorators","nodejs","serverless"],"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/SkippyZA.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-12T06:37:51.000Z","updated_at":"2019-12-17T18:33:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"c0dce50b-4dac-4d19-867c-7d808b033653","html_url":"https://github.com/SkippyZA/lambda-lib","commit_stats":{"total_commits":154,"total_committers":4,"mean_commits":38.5,"dds":0.03246753246753242,"last_synced_commit":"eefd5bbb8ad060e435d60bc8498f88170776179a"},"previous_names":[],"tags_count":37,"template":false,"template_full_name":null,"purl":"pkg:github/SkippyZA/lambda-lib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SkippyZA%2Flambda-lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SkippyZA%2Flambda-lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SkippyZA%2Flambda-lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SkippyZA%2Flambda-lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SkippyZA","download_url":"https://codeload.github.com/SkippyZA/lambda-lib/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SkippyZA%2Flambda-lib/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265558616,"owners_count":23787950,"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":["decorators","nodejs","serverless"],"created_at":"2024-11-13T05:13:48.652Z","updated_at":"2025-07-17T01:33:55.790Z","avatar_url":"https://github.com/SkippyZA.png","language":"JavaScript","readme":"[![Build Status](https://travis-ci.org/SkippyZA/lambda-lib.svg?branch=master)](https://travis-ci.org/SkippyZA/lambda-lib)\n[![License](https://img.shields.io/github/license/SkippyZA/lambda-lib.svg)](./LICENSE)\n[![NPM](https://img.shields.io/npm/v/lambda-lib.svg)](http://npmjs.com/package/lambda-lib)\n[![codecov](https://codecov.io/gh/SkippyZA/lambda-lib/branch/master/graph/badge.svg)](https://codecov.io/gh/SkippyZA/lambda-lib)\n\n# AWS Lambda Lib\n\nThis library contains a set of decorators to apply to AWS Lambda function to help abstract the event source\nand eliminate boilerplate code\n\n## Example\n\n```javascript\nimport { HandlerController, ApiGateway } from 'lambda-lib'\n\nconst errorMap = [\n  {\n    error: ReferenceError,\n    status: 400\n  },\n  {\n    error: Error,\n    status: 404\n  }\n]\n\n@HandlerController\nclass SampleLambdaHandler {\n  @ApiGateway({ statusCode: 200, cors: true })\n  helloHandler (event) {\n    return Promise.resolve({ hello: world })\n  }\n\n  @ApiGateway({ statusCode: 200, errorMap: errorMap })\n  failedHandler (event) {\n    return Promise.reject(new ReferenceError('I am a reference error'))\n  }\n}\n\nconst handler = new SampleLambdaHandler()\n\nexport default handler.getHandlers()\n```\n\n### Sample Response\n\n#### HelloHandler Response\n\n```bash\nHTTP/1.1 200 OK\nAccess-Control-Allow-Credentials: true\nAccess-Control-Allow-Methods: POST, GET, PUT, PATCH, DELETE, OPTIONS\nAccess-Control-Allow-Origin: *\nConnection: keep-alive\nContent-Type: application/json\nDate: Tue, 29 Aug 2017 17:07:04 GMT\naccept-ranges: bytes\ncache-control: no-cache\ncontent-length: 39\nvary: origin,accept-encoding\n\n{\n  \"hello\": \"world\"\n}\n```\n\n\n#### FailedHandler Response\n\n```bash\nHTTP/1.1 400 Bad Request\nConnection: keep-alive\nContent-Type: application/json\nDate: Tue, 29 Aug 2017 17:08:00 GMT\ncache-control: no-cache\ncontent-length: 398\nvary: accept-encoding\n\n{\n  \"error\": {\n    \"message\": \"I am a reference error\",\n    \"name\": \"ReferenceError\",\n    \"_stackTrace\": [\n      \"ReferenceError: I am a reference error\",\n      \"at SampleLambdaHandler.failedHandler (/.../src/resources/example/index.js:223:15)\",\n      \"at /.../node_modules/lambda-lib/lib/api-gateway.js:93:19\",\n      \"at process._tickDomainCallback (internal/process/next_tick.js:135:7)\"\n    ]\n  }\n}\n```\n\n## Specifying a custom error response\n\n```javascript\nimport { Plugins } from 'lambda-lib'\n\n// Registering a custom error response plugin. This is applied globally.\nApiGateway.registerPlugin(new Plugins.ErrorResponse(err =\u003e {\n  return {\n    test: 'This is the error response body for all errors',\n    error: err.message\n  }\n}))\n```\n\n#### Sample response with custom error\n\n```bash\nHTTP/1.1 400 Bad Request\nConnection: keep-alive\nContent-Type: application/json\nDate: Tue, 29 Aug 2017 17:08:00 GMT\ncache-control: no-cache\ncontent-length: 398\nvary: accept-encoding\n\n{\n  \"test\": \"This is the error response body for all errors\",\n  \"error\": \"I am a reference error\"\n}\n```\n\n## Included Plugins\n\n| Plugin           | Description                                                    |\n| ---------------- | -------------------------------------------------------------- |\n| cors             | When true, a set of default CORS headers are added to the response. Such as: `Access-Control-Allow-Origin`, `Access-Control-Allow-Credentials`, `Access-Control-Allow-Methods` |\n| statusCode       | Default status code for the response. Any object resolved via a Promise in the handler, will get this status code. |\n| errorMap         | Mapping of error types to response codes for rejected promises. |\n| errorResponse    | Format the response of an error. |\n\n## Plugin Hooks\n\n| Hook             | Description                                                    |\n| ---------------- | -------------------------------------------------------------- |\n| INITIALIZE       | Initialize is executed right at the beginning of the request, before any default plugins have been executed |\n| PRE_EXECUTE      | The pre execute hook is run right before the execution of handler code. |\n| POST_EXECUTE     | This hook, post execute, is run after the execution of the handler code. |\n| ON_ERROR         | When ever there is an error which results in a rejected promise, this hook is executed. |\n| FINALLY          | Final hook executed after the response has been sent to the client already. (Unable to manipulate response contents here) |\n\n## Writing your own plugin\n\nSee [built-in plugins](./src/plugins) for samples\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskippyza%2Flambda-lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskippyza%2Flambda-lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskippyza%2Flambda-lib/lists"}