{"id":15961185,"url":"https://github.com/pwntus/node-aws-lambda-ag","last_synced_at":"2025-04-04T12:12:58.689Z","repository":{"id":113366382,"uuid":"91163868","full_name":"Pwntus/node-aws-lambda-ag","owner":"Pwntus","description":"Tiny AWS Node helper for API Gateway Lambda proxies","archived":false,"fork":false,"pushed_at":"2017-05-15T17:05:50.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-03T22:50:26.673Z","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/Pwntus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-13T09:36:19.000Z","updated_at":"2017-05-13T11:02:00.000Z","dependencies_parsed_at":"2023-03-30T20:04:44.762Z","dependency_job_id":null,"html_url":"https://github.com/Pwntus/node-aws-lambda-ag","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"50e307d4ad5af2fc3d48a0101bc51780a0820bbc"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pwntus%2Fnode-aws-lambda-ag","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pwntus%2Fnode-aws-lambda-ag/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pwntus%2Fnode-aws-lambda-ag/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pwntus%2Fnode-aws-lambda-ag/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Pwntus","download_url":"https://codeload.github.com/Pwntus/node-aws-lambda-ag/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247174468,"owners_count":20896078,"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-10-07T15:40:55.239Z","updated_at":"2025-04-04T12:12:58.670Z","avatar_url":"https://github.com/Pwntus.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Node AWS Lambda API Gateway\n\nA tiny AWS Node helper for [API Gateway Lambda proxies](http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-create-api-as-simple-proxy-for-lambda.html).\n\nUseful for handling gateway parameters (both query and body), require parameters, setting default values and responses.\n\n## Install\nUsing npm:\n```\nnpm install node-aws-lambda-ag --save\n```\n\n## Usage\n\n```javascript\nvar AG = require('node-aws-lambda-ag')\n\n// Using ES6 syntax \n// import AG from 'node-aws-lambda-ag'\n\n// Define expected API Gateway parameters\nconst PARAMS = [\n  {\n    name: 'category',\n    required: true,\n    default: 'none'\n  },\n  {\n    name: 'offset',\n    required: false,\n    default: 0\n  },\n  {\n    name: 'limit',\n    required: false,\n    default: 15\n  }\n]\n\nexport const main = (event, context, callback) =\u003e {\n  // Initialize the helper with predefined parameters\n  let ag = new AG(event, PARAMS, callback)\n\n  // Fetch parameters\n  console.log('Got param: ', ag.param('category'))\n\n  // Send failed response\n  if (ag.param('limit') \u003e 100)\n    ag.failure({ error: 'Limit overflow' })\n\n  // Send successful response\n  else\n    ag.success({ status: 'ok' })\n}\n```\n\nIf a callback method is provided and a required parameter is absent in the event object, a failed response will automatically be issued.\n\n## API\n#### Constructor\n```javascript\nconstructor(event, params, callback = null)\n```\n- **event** (object) - the AWS Lambda [event](http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html).\n- **params** (array) - your predefined parameters.\n- **callback** (function, optional) - the [callback](http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html#nodejs-prog-model-handler-callback) function used by responses.\n\n#### Retrieveing a parameter\n```javascript\nAG.param(name)\n```\n- **name** (string) - the name of the param to retrieve. If the param was not provided in the request a predefined default value will be returned. If no default value is defined, or the param is non-existing, `null` will be returned.\n\n#### Sending a success response\n```javascript\nAG.success(response)\n```\n- **response** (object) - send a status 200 response with the provided object.\n\n#### Sending a failed response\n```javascript\nAG.failure(response, statusCode = 500)\n```\n- **response** (object) - send a status 500 response with the provided object.\n- **statusCode** (number, optional) - specify the HTTP status code.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpwntus%2Fnode-aws-lambda-ag","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpwntus%2Fnode-aws-lambda-ag","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpwntus%2Fnode-aws-lambda-ag/lists"}